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
93b2c58c
Commit
93b2c58c
authored
4 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Corrected bug where embeddings were not loaded when training resumed
parent
29907cb5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
reading_machine/include/ReadingMachine.hpp
+1
-0
1 addition, 0 deletions
reading_machine/include/ReadingMachine.hpp
reading_machine/src/ReadingMachine.cpp
+7
-3
7 additions, 3 deletions
reading_machine/src/ReadingMachine.cpp
trainer/src/MacaonTrain.cpp
+3
-2
3 additions, 2 deletions
trainer/src/MacaonTrain.cpp
with
11 additions
and
5 deletions
reading_machine/include/ReadingMachine.hpp
+
1
−
0
View file @
93b2c58c
...
@@ -53,6 +53,7 @@ class ReadingMachine
...
@@ -53,6 +53,7 @@ class ReadingMachine
void
saveLast
()
const
;
void
saveLast
()
const
;
void
saveDicts
()
const
;
void
saveDicts
()
const
;
bool
dictsAreNew
()
const
;
bool
dictsAreNew
()
const
;
void
loadLastSaved
();
};
};
#endif
#endif
This diff is collapsed.
Click to expand it.
reading_machine/src/ReadingMachine.cpp
+
7
−
3
View file @
93b2c58c
...
@@ -5,10 +5,7 @@ ReadingMachine::ReadingMachine(std::filesystem::path path) : path(path)
...
@@ -5,10 +5,7 @@ ReadingMachine::ReadingMachine(std::filesystem::path path) : path(path)
{
{
readFromFile
(
path
);
readFromFile
(
path
);
auto
lastSavedModel
=
util
::
findFilesByExtension
(
path
.
parent_path
(),
fmt
::
format
(
ReadingMachine
::
lastModelFilename
,
""
));
auto
savedDicts
=
util
::
findFilesByExtension
(
path
.
parent_path
(),
fmt
::
format
(
ReadingMachine
::
defaultDictFilename
,
""
));
auto
savedDicts
=
util
::
findFilesByExtension
(
path
.
parent_path
(),
fmt
::
format
(
ReadingMachine
::
defaultDictFilename
,
""
));
if
(
!
lastSavedModel
.
empty
())
torch
::
load
(
classifier
->
getNN
(),
lastSavedModel
[
0
]);
for
(
auto
path
:
savedDicts
)
for
(
auto
path
:
savedDicts
)
this
->
dicts
.
emplace
(
path
.
stem
().
string
(),
Dict
{
path
.
c_str
(),
Dict
::
State
::
Open
});
this
->
dicts
.
emplace
(
path
.
stem
().
string
(),
Dict
{
path
.
c_str
(),
Dict
::
State
::
Open
});
...
@@ -207,3 +204,10 @@ bool ReadingMachine::dictsAreNew() const
...
@@ -207,3 +204,10 @@ bool ReadingMachine::dictsAreNew() const
return
_dictsAreNew
;
return
_dictsAreNew
;
}
}
void
ReadingMachine
::
loadLastSaved
()
{
auto
lastSavedModel
=
util
::
findFilesByExtension
(
path
.
parent_path
(),
fmt
::
format
(
ReadingMachine
::
lastModelFilename
,
""
));
if
(
!
lastSavedModel
.
empty
())
torch
::
load
(
classifier
->
getNN
(),
lastSavedModel
[
0
]);
}
This diff is collapsed.
Click to expand it.
trainer/src/MacaonTrain.cpp
+
3
−
2
View file @
93b2c58c
...
@@ -106,8 +106,6 @@ int MacaonTrain::main()
...
@@ -106,8 +106,6 @@ int MacaonTrain::main()
ReadingMachine
machine
(
machinePath
.
string
());
ReadingMachine
machine
(
machinePath
.
string
());
fmt
::
print
(
stderr
,
"[{}] Model has {} parameters
\n
"
,
util
::
getTime
(),
util
::
int2HumanStr
(
machine
.
getClassifier
()
->
getNbParameters
()));
BaseConfig
goldConfig
(
mcdFile
,
trainTsvFile
,
trainRawFile
);
BaseConfig
goldConfig
(
mcdFile
,
trainTsvFile
,
trainRawFile
);
BaseConfig
devGoldConfig
(
mcdFile
,
computeDevScore
?
(
devRawFile
.
empty
()
?
devTsvFile
:
""
)
:
devTsvFile
,
devRawFile
);
BaseConfig
devGoldConfig
(
mcdFile
,
computeDevScore
?
(
devRawFile
.
empty
()
?
devTsvFile
:
""
)
:
devTsvFile
,
devRawFile
);
...
@@ -136,8 +134,11 @@ int MacaonTrain::main()
...
@@ -136,8 +134,11 @@ int MacaonTrain::main()
for
(
auto
&
it
:
machine
.
getDicts
())
for
(
auto
&
it
:
machine
.
getDicts
())
maxDictSize
=
std
::
max
<
std
::
size_t
>
(
maxDictSize
,
it
.
second
.
size
());
maxDictSize
=
std
::
max
<
std
::
size_t
>
(
maxDictSize
,
it
.
second
.
size
());
machine
.
getClassifier
()
->
getNN
()
->
registerEmbeddings
(
maxDictSize
);
machine
.
getClassifier
()
->
getNN
()
->
registerEmbeddings
(
maxDictSize
);
machine
.
loadLastSaved
();
machine
.
getClassifier
()
->
getNN
()
->
to
(
NeuralNetworkImpl
::
device
);
machine
.
getClassifier
()
->
getNN
()
->
to
(
NeuralNetworkImpl
::
device
);
fmt
::
print
(
stderr
,
"[{}] Model has {} parameters
\n
"
,
util
::
getTime
(),
util
::
int2HumanStr
(
machine
.
getClassifier
()
->
getNbParameters
()));
float
bestDevScore
=
computeDevScore
?
std
::
numeric_limits
<
float
>::
min
()
:
std
::
numeric_limits
<
float
>::
max
();
float
bestDevScore
=
computeDevScore
?
std
::
numeric_limits
<
float
>::
min
()
:
std
::
numeric_limits
<
float
>::
max
();
auto
trainInfos
=
machinePath
.
parent_path
()
/
"train.info"
;
auto
trainInfos
=
machinePath
.
parent_path
()
/
"train.info"
;
...
...
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