Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spiral
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Alexander Dielen
spiral
Commits
7a435e5d
Commit
7a435e5d
authored
6 years ago
by
Alexander Dielen
Browse files
Options
Downloads
Patches
Plain Diff
fixed initialization for the linear model
parent
8cac1989
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
train.py
+10
-0
10 additions, 0 deletions
train.py
with
11 additions
and
1 deletion
README.md
+
1
−
1
View file @
7a435e5d
...
...
@@ -42,7 +42,7 @@ Precomputed distances are optional and only required for evaluation purposes
python train.py --mode lstm
python train.py --mode linear
python train.py --mode linear
--epochs 4000
Model checkpoints and predictions on the validation and test sets are saved
to
`out/`
.
...
...
This diff is collapsed.
Click to expand it.
train.py
+
10
−
0
View file @
7a435e5d
...
...
@@ -20,6 +20,8 @@ class SpiralLayer(torch.nn.Module):
super
(
SpiralLayer
,
self
).
__init__
()
if
linear
:
self
.
layer
=
nn
.
Linear
(
in_features
*
seq_length
,
out_features
)
torch
.
nn
.
init
.
xavier_uniform_
(
self
.
layer
.
weight
,
gain
=
1
)
torch
.
nn
.
init
.
constant_
(
self
.
layer
.
bias
,
0
)
else
:
self
.
layer
=
nn
.
LSTM
(
in_features
,
out_features
,
batch_first
=
True
)
self
.
linear
=
linear
...
...
@@ -48,6 +50,14 @@ class SpiralNet(torch.nn.Module):
self
.
fc2
=
nn
.
Linear
(
outputs
[
2
],
256
)
self
.
fc3
=
nn
.
Linear
(
256
,
n_classes
)
if
linear
:
torch
.
nn
.
init
.
xavier_uniform_
(
self
.
fc1
.
weight
,
gain
=
1
)
torch
.
nn
.
init
.
xavier_uniform_
(
self
.
fc2
.
weight
,
gain
=
1
)
torch
.
nn
.
init
.
xavier_uniform_
(
self
.
fc3
.
weight
,
gain
=
1
)
torch
.
nn
.
init
.
constant_
(
self
.
fc1
.
bias
,
0
)
torch
.
nn
.
init
.
constant_
(
self
.
fc2
.
bias
,
0
)
torch
.
nn
.
init
.
constant_
(
self
.
fc3
.
bias
,
0
)
def
forward
(
self
,
x
,
indices
):
x
=
F
.
dropout
(
x
,
p
=
0.3
,
training
=
self
.
training
)
x
=
F
.
relu
(
self
.
fc1
(
x
))
...
...
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