Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
04e50aa9
Unverified
Commit
04e50aa9
authored
Dec 20, 2017
by
Asim Shankar
Committed by
GitHub
Dec 20, 2017
Browse files
Merge pull request #3034 from asimshankar/mnist-flags
[mnist]: Make flags function scoped (not module scoped).
parents
72f5834c
a367dc49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
39 deletions
+32
-39
official/mnist/mnist.py
official/mnist/mnist.py
+32
-39
No files found.
official/mnist/mnist.py
View file @
04e50aa9
...
@@ -24,45 +24,6 @@ import sys
...
@@ -24,45 +24,6 @@ import sys
import
tensorflow
as
tf
import
tensorflow
as
tf
from
tensorflow.examples.tutorials.mnist
import
input_data
from
tensorflow.examples.tutorials.mnist
import
input_data
parser
=
argparse
.
ArgumentParser
()
# Basic model parameters.
parser
.
add_argument
(
'--batch_size'
,
type
=
int
,
default
=
100
,
help
=
'Number of images to process in a batch'
)
parser
.
add_argument
(
'--data_dir'
,
type
=
str
,
default
=
'/tmp/mnist_data'
,
help
=
'Path to directory containing the MNIST dataset'
)
parser
.
add_argument
(
'--model_dir'
,
type
=
str
,
default
=
'/tmp/mnist_model'
,
help
=
'The directory where the model will be stored.'
)
parser
.
add_argument
(
'--train_epochs'
,
type
=
int
,
default
=
40
,
help
=
'Number of epochs to train.'
)
parser
.
add_argument
(
'--data_format'
,
type
=
str
,
default
=
None
,
choices
=
[
'channels_first'
,
'channels_last'
],
help
=
'A flag to override the data format used in the model. channels_first '
'provides a performance boost on GPU but is not always compatible '
'with CPU. If left unspecified, the data format will be chosen '
'automatically based on whether TensorFlow was built for CPU or GPU.'
)
parser
.
add_argument
(
'--export_dir'
,
type
=
str
,
help
=
'The directory where the exported SavedModel will be stored.'
)
def
train_dataset
(
data_dir
):
def
train_dataset
(
data_dir
):
"""Returns a tf.data.Dataset yielding (image, label) pairs for training."""
"""Returns a tf.data.Dataset yielding (image, label) pairs for training."""
...
@@ -220,6 +181,38 @@ def main(unused_argv):
...
@@ -220,6 +181,38 @@ def main(unused_argv):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--batch_size'
,
type
=
int
,
default
=
100
,
help
=
'Number of images to process in a batch'
)
parser
.
add_argument
(
'--data_dir'
,
type
=
str
,
default
=
'/tmp/mnist_data'
,
help
=
'Path to directory containing the MNIST dataset'
)
parser
.
add_argument
(
'--model_dir'
,
type
=
str
,
default
=
'/tmp/mnist_model'
,
help
=
'The directory where the model will be stored.'
)
parser
.
add_argument
(
'--train_epochs'
,
type
=
int
,
default
=
40
,
help
=
'Number of epochs to train.'
)
parser
.
add_argument
(
'--data_format'
,
type
=
str
,
default
=
None
,
choices
=
[
'channels_first'
,
'channels_last'
],
help
=
'A flag to override the data format used in the model. channels_first '
'provides a performance boost on GPU but is not always compatible '
'with CPU. If left unspecified, the data format will be chosen '
'automatically based on whether TensorFlow was built for CPU or GPU.'
)
parser
.
add_argument
(
'--export_dir'
,
type
=
str
,
help
=
'The directory where the exported SavedModel will be stored.'
)
tf
.
logging
.
set_verbosity
(
tf
.
logging
.
INFO
)
tf
.
logging
.
set_verbosity
(
tf
.
logging
.
INFO
)
FLAGS
,
unparsed
=
parser
.
parse_known_args
()
FLAGS
,
unparsed
=
parser
.
parse_known_args
()
tf
.
app
.
run
(
main
=
main
,
argv
=
[
sys
.
argv
[
0
]]
+
unparsed
)
tf
.
app
.
run
(
main
=
main
,
argv
=
[
sys
.
argv
[
0
]]
+
unparsed
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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