Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
old_macaon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Franck Dary
old_macaon
Commits
b0f2f464
Commit
b0f2f464
authored
6 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Made sure dynet is only initialized once
parent
d3876e0c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
MLP/include/MLP.hpp
+1
-0
1 addition, 0 deletions
MLP/include/MLP.hpp
MLP/src/MLP.cpp
+13
-2
13 additions, 2 deletions
MLP/src/MLP.cpp
with
14 additions
and
2 deletions
MLP/include/MLP.hpp
+
1
−
0
View file @
b0f2f464
...
@@ -69,6 +69,7 @@ class MLP
...
@@ -69,6 +69,7 @@ class MLP
void
loadStruct
(
const
std
::
string
&
filename
);
void
loadStruct
(
const
std
::
string
&
filename
);
void
loadParameters
(
const
std
::
string
&
filename
);
void
loadParameters
(
const
std
::
string
&
filename
);
void
load
(
const
std
::
string
&
filename
);
void
load
(
const
std
::
string
&
filename
);
void
initDynet
();
public
:
public
:
...
...
This diff is collapsed.
Click to expand it.
MLP/src/MLP.cpp
+
13
−
2
View file @
b0f2f464
...
@@ -67,10 +67,21 @@ MLP::Activation MLP::str2activation(std::string s)
...
@@ -67,10 +67,21 @@ MLP::Activation MLP::str2activation(std::string s)
return
LINEAR
;
return
LINEAR
;
}
}
void
MLP
::
initDynet
()
{
static
bool
init
=
false
;
if
(
init
)
return
;
init
=
true
;
dynet
::
initialize
(
getDefaultParams
());
}
MLP
::
MLP
(
std
::
vector
<
Layer
>
layers
)
MLP
::
MLP
(
std
::
vector
<
Layer
>
layers
)
:
layers
(
layers
),
trainer
(
model
,
0.001
,
0.9
,
0.999
,
1e-8
)
:
layers
(
layers
),
trainer
(
model
,
0.001
,
0.9
,
0.999
,
1e-8
)
{
{
dynet
::
initialize
(
getDefaultParams
()
);
initDynet
(
);
trainMode
=
true
;
trainMode
=
true
;
dropoutActive
=
true
;
dropoutActive
=
true
;
...
@@ -441,7 +452,7 @@ void MLP::loadParameters(const std::string & filename)
...
@@ -441,7 +452,7 @@ void MLP::loadParameters(const std::string & filename)
MLP
::
MLP
(
const
std
::
string
&
filename
)
MLP
::
MLP
(
const
std
::
string
&
filename
)
:
trainer
(
model
,
0.001
,
0.9
,
0.999
,
1e-8
)
:
trainer
(
model
,
0.001
,
0.9
,
0.999
,
1e-8
)
{
{
dynet
::
initialize
(
getDefaultParams
()
);
initDynet
(
);
trainMode
=
false
;
trainMode
=
false
;
dropoutActive
=
false
;
dropoutActive
=
false
;
...
...
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