Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
7f4086da
Unverified
Commit
7f4086da
authored
Jun 28, 2021
by
Tomohiro Endo
Committed by
GitHub
Jun 28, 2021
Browse files
cuda() to to(device) (#3064)
Co-authored-by:
Quan (Andy) Gan
<
coin2028@hotmail.com
>
parent
2f43cdb3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
examples/pytorch/stgcn_wave/main.py
examples/pytorch/stgcn_wave/main.py
+1
-1
examples/pytorch/stgcn_wave/model.py
examples/pytorch/stgcn_wave/model.py
+2
-2
No files found.
examples/pytorch/stgcn_wave/main.py
View file @
7f4086da
...
@@ -91,7 +91,7 @@ test_iter = torch.utils.data.DataLoader(test_data, batch_size)
...
@@ -91,7 +91,7 @@ test_iter = torch.utils.data.DataLoader(test_data, batch_size)
loss
=
nn
.
MSELoss
()
loss
=
nn
.
MSELoss
()
G
=
G
.
to
(
device
)
G
=
G
.
to
(
device
)
model
=
STGCN_WAVE
(
blocks
,
n_his
,
n_route
,
G
,
drop_prob
,
num_layers
,
args
.
control_str
).
to
(
device
)
model
=
STGCN_WAVE
(
blocks
,
n_his
,
n_route
,
G
,
drop_prob
,
num_layers
,
device
,
args
.
control_str
).
to
(
device
)
optimizer
=
torch
.
optim
.
RMSprop
(
model
.
parameters
(),
lr
=
lr
)
optimizer
=
torch
.
optim
.
RMSprop
(
model
.
parameters
(),
lr
=
lr
)
scheduler
=
torch
.
optim
.
lr_scheduler
.
StepLR
(
optimizer
,
step_size
=
5
,
gamma
=
0.7
)
scheduler
=
torch
.
optim
.
lr_scheduler
.
StepLR
(
optimizer
,
step_size
=
5
,
gamma
=
0.7
)
...
...
examples/pytorch/stgcn_wave/model.py
View file @
7f4086da
...
@@ -71,7 +71,7 @@ class OutputLayer(nn.Module):
...
@@ -71,7 +71,7 @@ class OutputLayer(nn.Module):
return
self
.
fc
(
x_t2
)
return
self
.
fc
(
x_t2
)
class
STGCN_WAVE
(
nn
.
Module
):
class
STGCN_WAVE
(
nn
.
Module
):
def
__init__
(
self
,
c
,
T
,
n
,
Lk
,
p
,
num_layers
,
control_str
=
'TNTSTNTST'
):
def
__init__
(
self
,
c
,
T
,
n
,
Lk
,
p
,
num_layers
,
device
,
control_str
=
'TNTSTNTST'
):
super
(
STGCN_WAVE
,
self
).
__init__
()
super
(
STGCN_WAVE
,
self
).
__init__
()
self
.
control_str
=
control_str
# model structure controller
self
.
control_str
=
control_str
# model structure controller
self
.
num_layers
=
len
(
control_str
)
self
.
num_layers
=
len
(
control_str
)
...
@@ -90,7 +90,7 @@ class STGCN_WAVE(nn.Module):
...
@@ -90,7 +90,7 @@ class STGCN_WAVE(nn.Module):
self
.
layers
.
append
(
nn
.
LayerNorm
([
n
,
c
[
cnt
]]))
self
.
layers
.
append
(
nn
.
LayerNorm
([
n
,
c
[
cnt
]]))
self
.
output
=
OutputLayer
(
c
[
cnt
],
T
+
1
-
2
**
(
diapower
),
n
)
self
.
output
=
OutputLayer
(
c
[
cnt
],
T
+
1
-
2
**
(
diapower
),
n
)
for
layer
in
self
.
layers
:
for
layer
in
self
.
layers
:
layer
=
layer
.
cuda
(
)
layer
=
layer
.
to
(
device
)
def
forward
(
self
,
x
):
def
forward
(
self
,
x
):
for
i
in
range
(
self
.
num_layers
):
for
i
in
range
(
self
.
num_layers
):
i_layer
=
self
.
control_str
[
i
]
i_layer
=
self
.
control_str
[
i
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment