Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Franck Dary
macaon
Commits
2261c98b
Commit
2261c98b
authored
4 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug in RawInputLSTM where only last context was added to. Applying dropout after relu in MLP
parent
f6de0f30
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
torch_modules/include/LSTMNetwork.hpp
+0
-1
0 additions, 1 deletion
torch_modules/include/LSTMNetwork.hpp
torch_modules/src/MLP.cpp
+1
-1
1 addition, 1 deletion
torch_modules/src/MLP.cpp
torch_modules/src/RawInputLSTM.cpp
+14
-11
14 additions, 11 deletions
torch_modules/src/RawInputLSTM.cpp
with
15 additions
and
13 deletions
torch_modules/include/LSTMNetwork.hpp
+
0
−
1
View file @
2261c98b
...
...
@@ -15,7 +15,6 @@ class LSTMNetworkImpl : public NeuralNetworkImpl
torch
::
nn
::
Embedding
wordEmbeddings
{
nullptr
};
torch
::
nn
::
Dropout
embeddingsDropout
{
nullptr
};
torch
::
nn
::
Dropout
lstmDropout
{
nullptr
};
MLP
mlp
{
nullptr
};
ContextLSTM
contextLSTM
{
nullptr
};
...
...
This diff is collapsed.
Click to expand it.
torch_modules/src/MLP.cpp
+
1
−
1
View file @
2261c98b
...
...
@@ -19,7 +19,7 @@ torch::Tensor MLPImpl::forward(torch::Tensor input)
{
torch
::
Tensor
output
=
input
;
for
(
unsigned
int
i
=
0
;
i
<
layers
.
size
()
-
1
;
i
++
)
output
=
torch
::
relu
(
dropouts
[
i
]
(
layers
[
i
](
output
)));
output
=
dropouts
[
i
](
torch
::
relu
(
layers
[
i
](
output
)));
return
layers
.
back
()(
output
);
}
...
...
This diff is collapsed.
Click to expand it.
torch_modules/src/RawInputLSTM.cpp
+
14
−
11
View file @
2261c98b
...
...
@@ -25,16 +25,19 @@ void RawInputLSTMImpl::addToContext(std::vector<std::vector<long>> & context, Di
if
(
leftWindow
<
0
or
rightWindow
<
0
)
return
;
for
(
int
i
=
0
;
i
<
leftWindow
;
i
++
)
if
(
config
.
hasCharacter
(
config
.
getCharacterIndex
()
-
leftWindow
+
i
))
context
.
back
().
push_back
(
dict
.
getIndexOrInsert
(
fmt
::
format
(
"{}"
,
config
.
getLetter
(
config
.
getCharacterIndex
()
-
leftWindow
+
i
))));
else
context
.
back
().
push_back
(
dict
.
getIndexOrInsert
(
Dict
::
nullValueStr
));
for
(
int
i
=
0
;
i
<=
rightWindow
;
i
++
)
if
(
config
.
hasCharacter
(
config
.
getCharacterIndex
()
+
i
))
context
.
back
().
push_back
(
dict
.
getIndexOrInsert
(
fmt
::
format
(
"{}"
,
config
.
getLetter
(
config
.
getCharacterIndex
()
+
i
))));
else
context
.
back
().
push_back
(
dict
.
getIndexOrInsert
(
Dict
::
nullValueStr
));
for
(
auto
&
contextElement
:
context
)
{
for
(
int
i
=
0
;
i
<
leftWindow
;
i
++
)
if
(
config
.
hasCharacter
(
config
.
getCharacterIndex
()
-
leftWindow
+
i
))
contextElement
.
push_back
(
dict
.
getIndexOrInsert
(
fmt
::
format
(
"{}"
,
config
.
getLetter
(
config
.
getCharacterIndex
()
-
leftWindow
+
i
))));
else
contextElement
.
push_back
(
dict
.
getIndexOrInsert
(
Dict
::
nullValueStr
));
for
(
int
i
=
0
;
i
<=
rightWindow
;
i
++
)
if
(
config
.
hasCharacter
(
config
.
getCharacterIndex
()
+
i
))
contextElement
.
push_back
(
dict
.
getIndexOrInsert
(
fmt
::
format
(
"{}"
,
config
.
getLetter
(
config
.
getCharacterIndex
()
+
i
))));
else
contextElement
.
push_back
(
dict
.
getIndexOrInsert
(
Dict
::
nullValueStr
));
}
}
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