Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
old_macaon_data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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_data
Commits
5e1e67c2
Commit
5e1e67c2
authored
6 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Added a script to launch many experiments with differents hyperparameters
parent
2fff8ac1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
fr/findHyperparameters.py
+129
-0
129 additions, 0 deletions
fr/findHyperparameters.py
with
129 additions
and
0 deletions
fr/findHyperparameters.py
0 → 100755
+
129
−
0
View file @
5e1e67c2
#! /usr/bin/python3
import
sys
import
os
import
re
import
random
from
subprocess
import
Popen
import
time
import
datetime
def
printUsageAndExit
()
:
print
(
"
Usage :
"
,
sys
.
argv
[
0
],
"
templateFolder
"
)
exit
(
1
)
def
getRelevantFilenames
()
:
if
len
(
sys
.
argv
)
!=
2
:
printUsageAndExit
()
folder
=
sys
.
argv
[
1
]
if
not
os
.
path
.
isdir
(
folder
)
:
print
(
folder
,
"
doesn
'
t exist
"
)
printUsageAndExit
()
files
=
os
.
listdir
(
folder
)
fms
=
[
f
for
f
in
files
if
re
.
match
(
r
"
(.)*\.fm
"
,
f
)]
clas
=
[
f
for
f
in
files
if
re
.
match
(
r
"
(.)*\.cla
"
,
f
)]
dicts
=
[
f
for
f
in
files
if
re
.
match
(
r
"
(.)*\.dicts
"
,
f
)][
0
]
return
folder
,
fms
,
clas
,
dicts
def
generateTopology
()
:
activations
=
[
"
SIGMOID
"
,
"
TANH
"
,
"
RELU
"
,
"
ELU
"
,
"
LINEAR
"
,
"
SPARSEMAX
"
,
"
CUBE
"
,
"
SOFTMAX
"
]
minNeurons
=
10
maxNeurons
=
1000
maxLayers
=
5
topology
=
""
layers
=
random
.
randrange
(
1
,
maxLayers
+
1
)
for
i
in
range
(
layers
)
:
topology
+=
"
(
"
+
str
(
random
.
randrange
(
minNeurons
,
maxNeurons
))
+
"
,
"
+
random
.
choice
(
activations
)
+
"
,
"
+
str
(
random
.
randrange
(
0
,
101
)
/
100
)
+
"
)
"
return
topology
def
rewriteClaFile
(
claFile
)
:
f
=
open
(
claFile
,
"
r
"
)
totalFile
=
""
while
True
:
line
=
f
.
readline
();
if
len
(
line
)
==
0
:
break
if
re
.
match
(
r
"
Topology(.)*
"
,
line
)
:
line
=
"
Topology :
"
+
generateTopology
()
+
"
\n
"
totalFile
+=
line
f
.
close
()
f
=
open
(
claFile
,
"
w
"
)
f
.
write
(
totalFile
)
f
.
close
()
def
rewriteDictsFile
(
dictsFile
)
:
firstColSize
=
30
secondColSize
=
5
minNeurons
=
1
maxNeurons
=
300
f
=
open
(
dictsFile
,
"
r
"
)
totalFile
=
""
while
True
:
line
=
f
.
readline
();
if
len
(
line
)
==
0
:
break
if
not
re
.
match
(
r
"
#(.)*
"
,
line
)
:
neurons
=
str
(
random
.
randrange
(
minNeurons
,
maxNeurons
+
1
))
lineSplit
=
line
.
split
()
line
=
lineSplit
[
0
]
+
(
firstColSize
-
len
(
lineSplit
[
0
]))
*
"
"
+
neurons
+
(
secondColSize
-
len
(
neurons
))
*
"
"
+
lineSplit
[
2
]
+
"
\n
"
totalFile
+=
line
f
.
close
()
f
=
open
(
dictsFile
,
"
w
"
)
f
.
write
(
totalFile
)
f
.
close
()
def
done
(
p
):
return
p
.
poll
()
is
not
None
def
success
(
p
):
return
p
.
returncode
==
0
def
launchNewExperiment
(
folder
,
fms
,
clas
,
dicts
,
nbIter
)
:
time
.
sleep
(
1
)
for
cla
in
clas
:
rewriteClaFile
(
folder
+
"
/
"
+
cla
)
rewriteDictsFile
(
folder
+
"
/
"
+
dicts
)
date
=
str
(
datetime
.
datetime
.
now
().
time
())[:
8
]
print
(
date
,
"
: Launched experiment
"
,
expCount
)
return
Popen
([
"
./train.sh
"
,
folder
,
folder
+
"
_
"
+
str
(
expCount
),
"
-n
"
,
str
(
nbIter
)])
nbConcurentExperiments
=
20
nbIter
=
20
folder
,
fms
,
clas
,
dicts
=
getRelevantFilenames
()
experiments
=
[]
expCount
=
0
while
len
(
experiments
)
<
nbConcurentExperiments
:
experiments
.
append
(
launchNewExperiment
(
folder
,
fms
,
clas
,
dicts
,
nbIter
))
expCount
+=
1
while
True
:
time
.
sleep
(
5
)
for
exp
in
experiments
:
if
done
(
exp
)
:
exp
=
launchNewExperiment
(
folder
,
fms
,
clas
,
dicts
,
nbIter
)
expCount
+=
1
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