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
4bebd4a8
Commit
4bebd4a8
authored
5 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Added dropout layer to ConcatWordsNetwork
parent
fb4e0869
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/ConcatWordsNetwork.hpp
+1
-0
1 addition, 0 deletions
torch_modules/include/ConcatWordsNetwork.hpp
torch_modules/src/ConcatWordsNetwork.cpp
+2
-1
2 additions, 1 deletion
torch_modules/src/ConcatWordsNetwork.cpp
trainer/include/Trainer.hpp
+1
-1
1 addition, 1 deletion
trainer/include/Trainer.hpp
with
4 additions
and
2 deletions
torch_modules/include/ConcatWordsNetwork.hpp
+
1
−
0
View file @
4bebd4a8
...
...
@@ -10,6 +10,7 @@ class ConcatWordsNetworkImpl : public NeuralNetworkImpl
torch
::
nn
::
Embedding
wordEmbeddings
{
nullptr
};
torch
::
nn
::
Linear
linear1
{
nullptr
};
torch
::
nn
::
Linear
linear2
{
nullptr
};
torch
::
nn
::
Dropout
dropout
{
nullptr
};
public
:
...
...
This diff is collapsed.
Click to expand it.
torch_modules/src/ConcatWordsNetwork.cpp
+
2
−
1
View file @
4bebd4a8
...
...
@@ -10,12 +10,13 @@ ConcatWordsNetworkImpl::ConcatWordsNetworkImpl(int nbOutputs, int leftBorder, in
wordEmbeddings
=
register_module
(
"word_embeddings"
,
torch
::
nn
::
Embedding
(
torch
::
nn
::
EmbeddingOptions
(
50000
,
embeddingsSize
)));
linear1
=
register_module
(
"linear1"
,
torch
::
nn
::
Linear
(
getContextSize
()
*
embeddingsSize
,
500
));
linear2
=
register_module
(
"linear2"
,
torch
::
nn
::
Linear
(
500
,
nbOutputs
));
dropout
=
register_module
(
"dropout"
,
torch
::
nn
::
Dropout
(
0.3
));
}
torch
::
Tensor
ConcatWordsNetworkImpl
::
forward
(
torch
::
Tensor
input
)
{
// input dim = {batch, sequence, embeddings}
auto
wordsAsEmb
=
wordEmbeddings
(
input
);
auto
wordsAsEmb
=
dropout
(
wordEmbeddings
(
input
)
)
;
// reshaped dim = {batch, sequence of embeddings}
auto
reshaped
=
wordsAsEmb
.
dim
()
==
3
?
torch
::
reshape
(
wordsAsEmb
,
{
wordsAsEmb
.
size
(
0
),
wordsAsEmb
.
size
(
1
)
*
wordsAsEmb
.
size
(
2
)})
:
torch
::
reshape
(
wordsAsEmb
,
{
wordsAsEmb
.
size
(
0
)
*
wordsAsEmb
.
size
(
1
)});
...
...
This diff is collapsed.
Click to expand it.
trainer/include/Trainer.hpp
+
1
−
1
View file @
4bebd4a8
...
...
@@ -18,7 +18,7 @@ class Trainer
DataLoader
dataLoader
{
nullptr
};
std
::
unique_ptr
<
torch
::
optim
::
Adam
>
optimizer
;
std
::
size_t
epochNumber
{
0
};
int
batchSize
{
10
0
};
int
batchSize
{
5
0
};
int
nbExamples
{
0
};
public
:
...
...
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