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
Merge requests
!85
Porting to TF2
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Porting to TF2
tf2
into
master
Overview
8
Commits
24
Pipelines
5
Changes
9
1 unresolved thread
Hide all comments
Merged
Tiago de Freitas Pereira
requested to merge
tf2
into
master
4 years ago
Overview
8
Commits
24
Pipelines
5
Changes
9
1 unresolved thread
Hide all comments
Expand
Fixes
#75 (closed)
Edited
4 years ago
by
Amir MOHAMMADI
0
0
Merge request reports
Viewing commit
23e4c7c2
Prev
Next
Show latest version
9 files
+
0
−
691
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
9
Search (e.g. *.vue) (Ctrl+P)
23e4c7c2
remove more scripts
· 23e4c7c2
Amir MOHAMMADI
authored
4 years ago
bob/learn/tensorflow/script/cache_dataset.py deleted
100644 → 0
+
0
−
72
Options
#!/usr/bin/env python
"""
Trains networks using Tensorflow estimators.
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
logging
import
click
import
tensorflow
as
tf
from
bob.extension.scripts.click_helper
import
ConfigCommand
from
bob.extension.scripts.click_helper
import
ResourceOption
from
bob.extension.scripts.click_helper
import
log_parameters
from
bob.extension.scripts.click_helper
import
verbosity_option
from
..utils
import
is_argument_available
logger
=
logging
.
getLogger
(
__name__
)
@click.command
(
entry_point_group
=
"
bob.learn.tensorflow.config
"
,
cls
=
ConfigCommand
)
@click.option
(
"
--input-fn
"
,
"
-i
"
,
required
=
True
,
cls
=
ResourceOption
,
entry_point_group
=
"
bob.learn.tensorflow.input_fn
"
,
help
=
"
The ``input_fn`` that will return the features and labels.
"
"
You should call the dataset.cache(...) yourself in the input
"
"
function. If the ``input_fn`` accepts a ``cache_only`` argument,
"
"
it will be given as True.
"
,
)
@click.option
(
"
--mode
"
,
cls
=
ResourceOption
,
default
=
tf
.
estimator
.
ModeKeys
.
TRAIN
,
show_default
=
True
,
type
=
click
.
Choice
(
(
tf
.
estimator
.
ModeKeys
.
TRAIN
,
tf
.
estimator
.
ModeKeys
.
EVAL
,
tf
.
estimator
.
ModeKeys
.
PREDICT
,
)
),
help
=
"
mode value to be given to the input_fn.
"
,
)
@verbosity_option
(
cls
=
ResourceOption
)
def
cache_dataset
(
input_fn
,
mode
,
**
kwargs
):
"""
Trains networks using Tensorflow estimators.
"""
log_parameters
(
logger
)
kwargs
=
{}
if
is_argument_available
(
"
cache_only
"
,
input_fn
):
kwargs
[
"
cache_only
"
]
=
True
logger
.
info
(
"
cache_only as True will be passed to input_fn.
"
)
# call the input function manually
with
tf
.
compat
.
v1
.
Session
()
as
sess
:
data
=
input_fn
(
mode
,
**
kwargs
)
if
isinstance
(
data
,
tf
.
data
.
Dataset
):
iterator
=
tf
.
compat
.
v1
.
data
.
make_initializable_iterator
(
data
)
data
=
iterator
.
get_next
()
sess
.
run
(
iterator
.
initializer
)
sess
.
run
(
tf
.
compat
.
v1
.
initializers
.
global_variables
())
try
:
while
True
:
sess
.
run
(
data
)
except
tf
.
errors
.
OutOfRangeError
:
click
.
echo
(
"
Finished reading the dataset.
"
)
return
Loading