Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qgnn-tracking
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Quantum-FE
qgnn-tracking
Commits
4739f482
Commit
4739f482
authored
6 months ago
by
Matteo Argenton
Browse files
Options
Downloads
Patches
Plain Diff
add support for depth and hidden dim of mlp in CGNN
parent
a77e4a25
No related branches found
Branches containing commit
Tags
v0.1.0
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
qnetworks/CGNN.py
+10
-4
10 additions, 4 deletions
qnetworks/CGNN.py
tools/tools.py
+1
-1
1 addition, 1 deletion
tools/tools.py
with
11 additions
and
5 deletions
qnetworks/CGNN.py
+
10
−
4
View file @
4739f482
...
...
@@ -4,6 +4,8 @@ from flax import linen as nn
#### Define Edge Network
class
EdgeNet
(
nn
.
Module
):
hid_dim
:
int
c_depth
:
int
inner_mlp_dim
:
int
@nn.compact
def
__call__
(
self
,
X
,
Ri
,
Ro
):
...
...
@@ -13,8 +15,9 @@ class EdgeNet(nn.Module):
B
=
jnp
.
concatenate
([
bo
,
bi
],
axis
=
1
)
B
=
nn
.
Dense
(
self
.
hid_dim
)(
B
)
B
=
nn
.
tanh
(
B
)
for
_
in
range
(
self
.
c_depth
):
B
=
nn
.
Dense
(
self
.
inner_mlp_dim
)(
B
)
B
=
nn
.
tanh
(
B
)
B
=
nn
.
Dense
(
1
)(
B
)
B
=
nn
.
sigmoid
(
B
)
...
...
@@ -23,6 +26,8 @@ class EdgeNet(nn.Module):
#### Define Node Network
class
NodeNet
(
nn
.
Module
):
hid_dim
:
int
c_depth
:
int
inner_mlp_dim
:
int
@nn.compact
def
__call__
(
self
,
X
,
e
,
Ri
,
Ro
):
...
...
@@ -37,8 +42,9 @@ class NodeNet(nn.Module):
mo
=
jnp
.
tensordot
(
Rwo
,
bi
,
axes
=
([
1
],[
0
]))
M
=
jnp
.
concatenate
([
mi
,
mo
,
X
],
axis
=
1
)
M
=
nn
.
Dense
(
self
.
hid_dim
)(
M
)
M
=
nn
.
tanh
(
M
)
for
_
in
range
(
self
.
c_depth
):
M
=
nn
.
Dense
(
self
.
inner_mlp_dim
)(
M
)
M
=
nn
.
tanh
(
M
)
M
=
nn
.
Dense
(
self
.
hid_dim
)(
M
)
M
=
nn
.
sigmoid
(
M
)
...
...
This diff is collapsed.
Click to expand it.
tools/tools.py
+
1
−
1
View file @
4739f482
...
...
@@ -138,7 +138,7 @@ def model_setup(config, session_id=0):
NodeNet
(
config
[
'
NN_qc
'
][
'
n_qubits
'
],
config
[
'
hid_dim
'
],
QLayer
(
config
[
'
NN_qc
'
],
session_id
,
config
[
'
backend
'
])))
elif
config
[
'
network
'
]
==
'
CGNN
'
:
from
qnetworks.CGNN
import
GNN
,
EdgeNet
,
NodeNet
model
=
GNN
(
config
[
'
hid_dim
'
],
config
[
'
n_iters
'
],
EdgeNet
(
config
[
'
hid_dim
'
]
),
NodeNet
(
config
[
'
hid
_dim
'
]))
model
=
GNN
(
config
[
'
hid_dim
'
],
config
[
'
n_iters
'
],
EdgeNet
(
config
[
'
hid_dim
'
]
,
config
[
'
c_depth
'
],
config
[
'
inner_mlp_dim
'
]),
NodeNet
(
config
[
'
hid_dim
'
],
config
[
'
c_depth
'
],
config
[
'
inner_mlp
_dim
'
]))
else
:
print
(
'
Wrong network specification!
'
)
sys
.
exit
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment