Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.tensorflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.tensorflow
Commits
85089584
There was a problem fetching the pipeline summary.
Commit
85089584
authored
7 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Integrating with gridtk
parent
2e5982a7
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!14
gridtk integration
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/learn/tensorflow/script/train.py
+36
-15
36 additions, 15 deletions
bob/learn/tensorflow/script/train.py
bob/learn/tensorflow/test/test_train_script.py
+8
-3
8 additions, 3 deletions
bob/learn/tensorflow/test/test_train_script.py
with
44 additions
and
18 deletions
bob/learn/tensorflow/script/train.py
+
36
−
15
View file @
85089584
...
...
@@ -7,13 +7,14 @@
Train a Neural network using bob.learn.tensorflow
Usage:
train.py [--iterations=<arg> --validation-interval=<arg> --output-dir=<arg> ] <configuration>
train.py [--iterations=<arg> --validation-interval=<arg> --output-dir=<arg> ] <configuration>
[grid <jobs>]
train.py -h | --help
Options:
-h --help Show this screen.
--iterations=<arg> [default: 1000]
--validation-interval=<arg> [default:
1
00]
--output-dir=<arg> If the directory exists, will try to get the last checkpoint [default: ./logs/]
-h --help
Show this screen.
--iterations=<arg>
Number of iteratiosn
[default: 1000]
--validation-interval=<arg>
Validata every n iteratiosn
[default:
5
00]
--output-dir=<arg>
If the directory exists, will try to get the last checkpoint [default: ./logs/]
"""
from
docopt
import
docopt
...
...
@@ -21,31 +22,51 @@ import imp
import
bob.learn.tensorflow
import
tensorflow
as
tf
import
os
import
sys
def
dump_commandline
():
command_line
=
""
for
command
in
sys
.
argv
:
if
command
==
"
grid
"
:
break
command_line
+=
"
{0}
"
.
format
(
command
)
return
command_line
def
main
():
args
=
docopt
(
__doc__
,
version
=
'
Train Neural Net
'
)
OUTPUT_DIR
=
str
(
args
[
'
--output-dir
'
])
ITERATIONS
=
int
(
args
[
'
--iterations
'
])
output_dir
=
str
(
args
[
'
--output-dir
'
])
iterations
=
int
(
args
[
'
--iterations
'
])
grid
=
int
(
args
[
'
grid
'
])
if
grid
:
jobs
=
int
(
args
[
'
<jobs>
'
])
import
gridtk
job_manager
=
gridtk
.
sge
.
JobManagerSGE
()
command
=
dump_commandline
()
dependencies
=
[]
#PRETRAINED_NET = ""
#if not args['--pretrained-net'] is None:
#
PRETRAINED_NET = str(args['--pretrained-net'])
for
i
in
range
(
jobs
):
job_id
=
job_manager
.
submit
(
command
,
dependencies
=
dependencies
)
dependencies
=
[
job_id
]
config
=
imp
.
load_source
(
'
config
'
,
args
[
'
<configuration>
'
])
# Cleaning all variables in case you are loading the checkpoint
tf
.
reset_default_graph
()
if
os
.
path
.
exists
(
OUTPUT_DIR
)
else
None
tf
.
reset_default_graph
()
if
os
.
path
.
exists
(
output_dir
)
else
None
# One graph trainer
trainer
=
config
.
Trainer
(
config
.
train_data_shuffler
,
iterations
=
ITERATIONS
,
iterations
=
iterations
,
analizer
=
None
,
temp_dir
=
OUTPUT_DIR
)
if
os
.
path
.
exists
(
OUTPUT_DIR
):
temp_dir
=
output_dir
)
if
os
.
path
.
exists
(
output_dir
):
print
(
"
Directory already exists, trying to get the last checkpoint
"
)
trainer
.
create_network_from_file
(
OUTPUT_DIR
)
trainer
.
create_network_from_file
(
output_dir
)
else
:
# Preparing the architecture
...
...
This diff is collapsed.
Click to expand it.
bob/learn/tensorflow/test/test_train_script.py
+
8
−
3
View file @
85089584
...
...
@@ -5,6 +5,7 @@
import
pkg_resources
import
shutil
import
tensorflow
as
tf
def
test_train_script_softmax
():
...
...
@@ -18,7 +19,9 @@ def test_train_script_softmax():
# Continuing from the last checkpoint
call
([
"
./bin/train.py
"
,
"
--iterations
"
,
"
5
"
,
"
--output-dir
"
,
directory
,
train_script
])
shutil
.
rmtree
(
directory
)
assert
True
tf
.
reset_default_graph
()
assert
len
(
tf
.
global_variables
())
==
0
def
test_train_script_triplet
():
...
...
@@ -34,7 +37,8 @@ def test_train_script_triplet():
shutil
.
rmtree
(
directory
)
assert
True
tf
.
reset_default_graph
()
assert
len
(
tf
.
global_variables
())
==
0
def
test_train_script_siamese
():
...
...
@@ -50,4 +54,5 @@ def test_train_script_siamese():
shutil
.
rmtree
(
directory
)
assert
True
tf
.
reset_default_graph
()
assert
len
(
tf
.
global_variables
())
==
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