Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.learn.tensorflow
Commits
171ede05
Commit
171ede05
authored
Sep 28, 2017
by
Tiago de Freitas Pereira
Browse files
Patched the train.py script to accept tensors as input
parent
9359b23d
Pipeline
#12834
passed with stages
in 13 minutes and 11 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/learn/tensorflow/script/train.py
View file @
171ede05
...
...
@@ -87,22 +87,34 @@ def main():
trainer
.
create_network_from_file
(
output_dir
)
else
:
# Preparing the architecture
input_pl
=
config
.
train_data_shuffler
(
"data"
,
from_queue
=
False
)
if
isinstance
(
trainer
,
bob
.
learn
.
tensorflow
.
trainers
.
SiameseTrainer
):
graph
=
dict
()
graph
[
'left'
]
=
config
.
architecture
(
input_pl
[
'left'
])
graph
[
'right'
]
=
config
.
architecture
(
input_pl
[
'right'
],
reuse
=
True
)
elif
isinstance
(
trainer
,
bob
.
learn
.
tensorflow
.
trainers
.
TripletTrainer
):
graph
=
dict
()
graph
[
'anchor'
]
=
config
.
architecture
(
input_pl
[
'anchor'
])
graph
[
'positive'
]
=
config
.
architecture
(
input_pl
[
'positive'
],
reuse
=
True
)
graph
[
'negative'
]
=
config
.
architecture
(
input_pl
[
'negative'
],
reuse
=
True
)
# Either bootstrap from scratch or take the pointer directly from the config script
train_graph
=
None
validation_graph
=
None
if
hasattr
(
config
,
'train_graph'
):
train_graph
=
config
.
train_graph
if
hasattr
(
config
,
'validation_graph'
):
validation_graph
=
config
.
validation_graph
else
:
graph
=
config
.
architecture
(
input_pl
)
trainer
.
create_network_from_scratch
(
graph
,
loss
=
config
.
loss
,
# Preparing the architecture
input_pl
=
config
.
train_data_shuffler
(
"data"
,
from_queue
=
False
)
if
isinstance
(
trainer
,
bob
.
learn
.
tensorflow
.
trainers
.
SiameseTrainer
):
train_graph
=
dict
()
train_graph
[
'left'
]
=
config
.
architecture
(
input_pl
[
'left'
])
train_graph
[
'right'
]
=
config
.
architecture
(
input_pl
[
'right'
],
reuse
=
True
)
elif
isinstance
(
trainer
,
bob
.
learn
.
tensorflow
.
trainers
.
TripletTrainer
):
train_graph
=
dict
()
train_graph
[
'anchor'
]
=
config
.
architecture
(
input_pl
[
'anchor'
])
train_graph
[
'positive'
]
=
config
.
architecture
(
input_pl
[
'positive'
],
reuse
=
True
)
train_graph
[
'negative'
]
=
config
.
architecture
(
input_pl
[
'negative'
],
reuse
=
True
)
else
:
train_graph
=
config
.
architecture
(
input_pl
)
trainer
.
create_network_from_scratch
(
train_graph
,
validation_graph
=
validation_graph
,
loss
=
config
.
loss
,
learning_rate
=
config
.
learning_rate
,
optimizer
=
config
.
optimizer
)
trainer
.
train
()
...
...
bob/learn/tensorflow/trainers/SiameseTrainer.py
View file @
171ede05
...
...
@@ -121,6 +121,7 @@ class SiameseTrainer(Trainer):
def
create_network_from_scratch
(
self
,
graph
,
validation_graph
=
None
,
optimizer
=
tf
.
train
.
AdamOptimizer
(),
loss
=
None
,
...
...
bob/learn/tensorflow/trainers/Trainer.py
View file @
171ede05
...
...
@@ -59,8 +59,8 @@ class Trainer(object):
###### training options ##########
iterations
=
5000
,
snapshot
=
5
00
,
validation_snapshot
=
1
00
,
snapshot
=
10
00
,
validation_snapshot
=
20
00
,
keep_checkpoint_every_n_hours
=
2
,
## Analizer
...
...
bob/learn/tensorflow/trainers/TripletTrainer.py
View file @
171ede05
...
...
@@ -122,6 +122,7 @@ class TripletTrainer(Trainer):
def
create_network_from_scratch
(
self
,
graph
,
validation_graph
=
None
,
optimizer
=
tf
.
train
.
AdamOptimizer
(),
loss
=
None
,
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment