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
0344090e
Commit
0344090e
authored
6 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
WIP : added a way to launch multiple experiments
parent
5d1d99f1
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
maca_common/include/ProgramParameters.hpp
+3
-0
3 additions, 0 deletions
maca_common/include/ProgramParameters.hpp
maca_common/src/ProgramParameters.cpp
+3
-0
3 additions, 0 deletions
maca_common/src/ProgramParameters.cpp
trainer/src/macaon_train.cpp
+85
-33
85 additions, 33 deletions
trainer/src/macaon_train.cpp
with
91 additions
and
33 deletions
maca_common/include/ProgramParameters.hpp
+
3
−
0
View file @
0344090e
...
@@ -12,6 +12,9 @@ struct ProgramParameters
...
@@ -12,6 +12,9 @@ struct ProgramParameters
static
std
::
string
input
;
static
std
::
string
input
;
static
std
::
string
expName
;
static
std
::
string
expName
;
static
std
::
string
expPath
;
static
std
::
string
expPath
;
static
std
::
string
langPath
;
static
std
::
string
templatePath
;
static
std
::
string
templateName
;
static
std
::
string
tmFilename
;
static
std
::
string
tmFilename
;
static
std
::
string
tmName
;
static
std
::
string
tmName
;
static
std
::
string
bdFilename
;
static
std
::
string
bdFilename
;
...
...
This diff is collapsed.
Click to expand it.
maca_common/src/ProgramParameters.cpp
+
3
−
0
View file @
0344090e
...
@@ -7,6 +7,9 @@ ProgramParameters::ProgramParameters()
...
@@ -7,6 +7,9 @@ ProgramParameters::ProgramParameters()
std
::
string
ProgramParameters
::
input
;
std
::
string
ProgramParameters
::
input
;
std
::
string
ProgramParameters
::
expName
;
std
::
string
ProgramParameters
::
expName
;
std
::
string
ProgramParameters
::
expPath
;
std
::
string
ProgramParameters
::
expPath
;
std
::
string
ProgramParameters
::
langPath
;
std
::
string
ProgramParameters
::
templatePath
;
std
::
string
ProgramParameters
::
templateName
;
std
::
string
ProgramParameters
::
tmFilename
;
std
::
string
ProgramParameters
::
tmFilename
;
std
::
string
ProgramParameters
::
tmName
;
std
::
string
ProgramParameters
::
tmName
;
std
::
string
ProgramParameters
::
bdFilename
;
std
::
string
ProgramParameters
::
bdFilename
;
...
...
This diff is collapsed.
Click to expand it.
trainer/src/macaon_train.cpp
+
85
−
33
View file @
0344090e
...
@@ -25,6 +25,8 @@ po::options_description getOptionsDescription()
...
@@ -25,6 +25,8 @@ po::options_description getOptionsDescription()
req
.
add_options
()
req
.
add_options
()
(
"expName"
,
po
::
value
<
std
::
string
>
()
->
required
(),
(
"expName"
,
po
::
value
<
std
::
string
>
()
->
required
(),
"Name of this experiment"
)
"Name of this experiment"
)
(
"templateName"
,
po
::
value
<
std
::
string
>
()
->
required
(),
"Name of the template folder"
)
(
"tm"
,
po
::
value
<
std
::
string
>
()
->
required
(),
(
"tm"
,
po
::
value
<
std
::
string
>
()
->
required
(),
"File describing the Tape Machine we will train"
)
"File describing the Tape Machine we will train"
)
(
"bd"
,
po
::
value
<
std
::
string
>
()
->
required
(),
(
"bd"
,
po
::
value
<
std
::
string
>
()
->
required
(),
...
@@ -47,7 +49,7 @@ po::options_description getOptionsDescription()
...
@@ -47,7 +49,7 @@ po::options_description getOptionsDescription()
(
"nbiter,n"
,
po
::
value
<
int
>
()
->
default_value
(
5
),
(
"nbiter,n"
,
po
::
value
<
int
>
()
->
default_value
(
5
),
"Number of training epochs (iterations)"
)
"Number of training epochs (iterations)"
)
(
"iterationSize"
,
po
::
value
<
int
>
()
->
default_value
(
-
1
),
(
"iterationSize"
,
po
::
value
<
int
>
()
->
default_value
(
-
1
),
"The number of examples for each iteration. -1 means the whole training set
.
"
)
"The number of examples for each iteration. -1 means the whole training set"
)
(
"lr"
,
po
::
value
<
float
>
()
->
default_value
(
0.001
),
(
"lr"
,
po
::
value
<
float
>
()
->
default_value
(
0.001
),
"Learning rate of the optimizer"
)
"Learning rate of the optimizer"
)
(
"seed,s"
,
po
::
value
<
int
>
()
->
default_value
(
100
),
(
"seed,s"
,
po
::
value
<
int
>
()
->
default_value
(
100
),
...
@@ -118,6 +120,82 @@ po::variables_map checkOptions(po::options_description & od, int argc, char ** a
...
@@ -118,6 +120,82 @@ po::variables_map checkOptions(po::options_description & od, int argc, char ** a
return
vm
;
return
vm
;
}
}
/// @brief Set all the usefull paths relative to expPath
void
updatePaths
()
{
const
char
*
MACAON_DIR
=
std
::
getenv
(
"MACAON_DIR"
);
std
::
string
slash
=
"/"
;
ProgramParameters
::
langPath
=
MACAON_DIR
+
slash
+
ProgramParameters
::
lang
+
slash
;
ProgramParameters
::
expPath
=
ProgramParameters
::
langPath
+
"bin/"
+
ProgramParameters
::
expName
+
slash
;
ProgramParameters
::
templatePath
=
ProgramParameters
::
langPath
+
ProgramParameters
::
templateName
+
slash
;
ProgramParameters
::
tmFilename
=
ProgramParameters
::
expPath
+
ProgramParameters
::
tmName
;
ProgramParameters
::
bdFilename
=
ProgramParameters
::
expPath
+
ProgramParameters
::
bdName
;
ProgramParameters
::
mcdFilename
=
ProgramParameters
::
expPath
+
ProgramParameters
::
mcdName
;
ProgramParameters
::
trainFilename
=
ProgramParameters
::
expPath
+
ProgramParameters
::
trainName
;
ProgramParameters
::
devFilename
=
ProgramParameters
::
expPath
+
ProgramParameters
::
devName
;
}
/// @brief Create the folder containing the current experiment from the template frolder
void
createExpPath
()
{
std
::
string
decode
=
"\
#! /bin/bash
\n
\
\n
\
if [
\"
$#
\"
-lt 2 ]; then
\n
\
echo
\"
Usage : $0 input mcd
\"\n
\
exit
\n
\
fi
\n
\
\n
\
INPUT=$1
\n
\
MCD=$2
\n
\
\n
\
shift
\n
\
shift
\n
\
ARGS=
\"\"\n
\
for arg in
\"
$@
\"\n
\
do
\n
\
ARGS=
\"
$ARGS $arg
\"\n
\
done
\n
\
\n
\
macaon_decode --lang $LANG --tm machine.tm --bd test.bd -I $INPUT --mcd $MCD --expName "
+
ProgramParameters
::
expName
+
"$ARGS"
;
if
(
system
((
"rm -r "
+
ProgramParameters
::
expPath
+
" 2> /dev/null"
).
c_str
())){}
if
(
system
((
"mkdir "
+
ProgramParameters
::
expPath
).
c_str
())){}
if
(
system
((
"cp -r "
+
ProgramParameters
::
templatePath
+
"* "
+
ProgramParameters
::
expPath
+
"."
).
c_str
())){}
if
(
system
((
"echo
\'
"
+
decode
+
"
\'
> "
+
ProgramParameters
::
expPath
+
"decode.sh"
).
c_str
())){}
if
(
system
((
"chmod +x "
+
ProgramParameters
::
expPath
+
"decode.sh"
).
c_str
())){}
if
(
system
((
"ln -f -s "
+
ProgramParameters
::
expPath
+
"decode.sh "
+
ProgramParameters
::
langPath
+
"bin/maca_tm_"
+
ProgramParameters
::
expName
).
c_str
())){}
}
/// @brief Train a model according to all the ProgramParameters
void
launchTraining
()
{
TransitionMachine
transitionMachine
(
true
);
BD
trainBD
(
ProgramParameters
::
bdFilename
,
ProgramParameters
::
mcdFilename
);
Config
trainConfig
(
trainBD
);
trainConfig
.
readInput
(
ProgramParameters
::
trainFilename
);
std
::
unique_ptr
<
BD
>
devBD
;
std
::
unique_ptr
<
Config
>
devConfig
;
std
::
unique_ptr
<
Trainer
>
trainer
;
if
(
ProgramParameters
::
devFilename
.
empty
())
{
trainer
.
reset
(
new
Trainer
(
transitionMachine
,
trainBD
,
trainConfig
));
}
else
{
devBD
.
reset
(
new
BD
(
ProgramParameters
::
bdFilename
,
ProgramParameters
::
mcdFilename
));
devConfig
.
reset
(
new
Config
(
*
devBD
.
get
()));
devConfig
->
readInput
(
ProgramParameters
::
devFilename
);
trainer
.
reset
(
new
Trainer
(
transitionMachine
,
trainBD
,
trainConfig
,
devBD
.
get
(),
devConfig
.
get
()));
}
trainer
->
train
();
}
/// @brief Train a TransitionMachine to predict and add information to a structured input file, by using annotated examples.
/// @brief Train a TransitionMachine to predict and add information to a structured input file, by using annotated examples.
///
///
/// @param argc The number of arguments given to this program.
/// @param argc The number of arguments given to this program.
...
@@ -131,6 +209,7 @@ int main(int argc, char * argv[])
...
@@ -131,6 +209,7 @@ int main(int argc, char * argv[])
po
::
variables_map
vm
=
checkOptions
(
od
,
argc
,
argv
);
po
::
variables_map
vm
=
checkOptions
(
od
,
argc
,
argv
);
ProgramParameters
::
expName
=
vm
[
"expName"
].
as
<
std
::
string
>
();
ProgramParameters
::
expName
=
vm
[
"expName"
].
as
<
std
::
string
>
();
ProgramParameters
::
templateName
=
vm
[
"templateName"
].
as
<
std
::
string
>
();
ProgramParameters
::
tmName
=
vm
[
"tm"
].
as
<
std
::
string
>
();
ProgramParameters
::
tmName
=
vm
[
"tm"
].
as
<
std
::
string
>
();
ProgramParameters
::
bdName
=
vm
[
"bd"
].
as
<
std
::
string
>
();
ProgramParameters
::
bdName
=
vm
[
"bd"
].
as
<
std
::
string
>
();
ProgramParameters
::
mcdName
=
vm
[
"mcd"
].
as
<
std
::
string
>
();
ProgramParameters
::
mcdName
=
vm
[
"mcd"
].
as
<
std
::
string
>
();
...
@@ -153,40 +232,13 @@ int main(int argc, char * argv[])
...
@@ -153,40 +232,13 @@ int main(int argc, char * argv[])
ProgramParameters
::
showFeatureRepresentation
=
vm
[
"showFeatureRepresentation"
].
as
<
bool
>
();
ProgramParameters
::
showFeatureRepresentation
=
vm
[
"showFeatureRepresentation"
].
as
<
bool
>
();
ProgramParameters
::
iterationSize
=
vm
[
"iterationSize"
].
as
<
int
>
();
ProgramParameters
::
iterationSize
=
vm
[
"iterationSize"
].
as
<
int
>
();
const
char
*
MACAON_DIR
=
std
::
getenv
(
"MACAON_DIR"
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
std
::
string
slash
=
"/"
;
ProgramParameters
::
expPath
=
MACAON_DIR
+
slash
+
ProgramParameters
::
lang
+
slash
+
"bin/"
+
ProgramParameters
::
expName
+
slash
;
ProgramParameters
::
tmFilename
=
ProgramParameters
::
expPath
+
ProgramParameters
::
tmName
;
ProgramParameters
::
bdFilename
=
ProgramParameters
::
expPath
+
ProgramParameters
::
bdName
;
ProgramParameters
::
mcdFilename
=
ProgramParameters
::
expPath
+
ProgramParameters
::
mcdName
;
ProgramParameters
::
trainFilename
=
ProgramParameters
::
expPath
+
ProgramParameters
::
trainName
;
ProgramParameters
::
devFilename
=
ProgramParameters
::
expPath
+
ProgramParameters
::
devName
;
TransitionMachine
transitionMachine
(
true
);
BD
trainBD
(
ProgramParameters
::
bdFilename
,
ProgramParameters
::
mcdFilename
);
Config
trainConfig
(
trainBD
);
trainConfig
.
readInput
(
ProgramParameters
::
trainFilename
);
std
::
unique_ptr
<
BD
>
devBD
;
std
::
unique_ptr
<
Config
>
devConfig
;
std
::
unique_ptr
<
Trainer
>
trainer
;
if
(
ProgramParameters
::
devFilename
.
empty
())
{
{
trainer
.
reset
(
new
Trainer
(
transitionMachine
,
trainBD
,
trainConfig
));
ProgramParameters
::
expName
+=
"_"
+
std
::
to_string
(
i
);
updatePaths
();
createExpPath
();
launchTraining
();
}
}
else
{
devBD
.
reset
(
new
BD
(
ProgramParameters
::
bdFilename
,
ProgramParameters
::
mcdFilename
));
devConfig
.
reset
(
new
Config
(
*
devBD
.
get
()));
devConfig
->
readInput
(
ProgramParameters
::
devFilename
);
trainer
.
reset
(
new
Trainer
(
transitionMachine
,
trainBD
,
trainConfig
,
devBD
.
get
(),
devConfig
.
get
()));
}
trainer
->
train
();
return
0
;
return
0
;
}
}
...
...
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