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
a552e76a
Unverified
Commit
a552e76a
authored
Jul 31, 2019
by
Toby Boyd
Committed by
GitHub
Jul 31, 2019
Browse files
Change to experimental_run_tf_function. (#7344)
parent
480d2630
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
22 deletions
+25
-22
official/recommendation/ncf_keras_main.py
official/recommendation/ncf_keras_main.py
+4
-3
official/resnet/keras/keras_cifar_main.py
official/resnet/keras/keras_cifar_main.py
+7
-6
official/resnet/keras/keras_imagenet_main.py
official/resnet/keras/keras_imagenet_main.py
+7
-6
official/staging/shakespeare/shakespeare_main.py
official/staging/shakespeare/shakespeare_main.py
+7
-7
No files found.
official/recommendation/ncf_keras_main.py
View file @
a552e76a
...
@@ -370,9 +370,10 @@ def run_ncf(_):
...
@@ -370,9 +370,10 @@ def run_ncf(_):
else
:
else
:
with
distribution_utils
.
get_strategy_scope
(
strategy
):
with
distribution_utils
.
get_strategy_scope
(
strategy
):
keras_model
.
compile
(
optimizer
=
optimizer
,
keras_model
.
compile
(
run_eagerly
=
FLAGS
.
run_eagerly
,
optimizer
=
optimizer
,
run_distributed
=
FLAGS
.
force_v2_in_keras_compile
)
run_eagerly
=
FLAGS
.
run_eagerly
,
experimental_run_tf_function
=
FLAGS
.
force_v2_in_keras_compile
)
history
=
keras_model
.
fit
(
history
=
keras_model
.
fit
(
train_input_dataset
,
train_input_dataset
,
...
...
official/resnet/keras/keras_cifar_main.py
View file @
a552e76a
...
@@ -177,12 +177,13 @@ def run(flags_obj):
...
@@ -177,12 +177,13 @@ def run(flags_obj):
optimizer
=
keras_common
.
get_optimizer
()
optimizer
=
keras_common
.
get_optimizer
()
model
=
resnet_cifar_model
.
resnet56
(
classes
=
cifar_main
.
NUM_CLASSES
)
model
=
resnet_cifar_model
.
resnet56
(
classes
=
cifar_main
.
NUM_CLASSES
)
model
.
compile
(
loss
=
'categorical_crossentropy'
,
model
.
compile
(
optimizer
=
optimizer
,
loss
=
'categorical_crossentropy'
,
metrics
=
([
'categorical_accuracy'
]
optimizer
=
optimizer
,
if
flags_obj
.
report_accuracy_metrics
else
None
),
metrics
=
([
'categorical_accuracy'
]
run_eagerly
=
flags_obj
.
run_eagerly
,
if
flags_obj
.
report_accuracy_metrics
else
None
),
run_distributed
=
flags_obj
.
force_v2_in_keras_compile
)
run_eagerly
=
flags_obj
.
run_eagerly
,
experimental_run_tf_function
=
flags_obj
.
force_v2_in_keras_compile
)
callbacks
=
keras_common
.
get_callbacks
(
callbacks
=
keras_common
.
get_callbacks
(
learning_rate_schedule
,
cifar_main
.
NUM_IMAGES
[
'train'
])
learning_rate_schedule
,
cifar_main
.
NUM_IMAGES
[
'train'
])
...
...
official/resnet/keras/keras_imagenet_main.py
View file @
a552e76a
...
@@ -201,12 +201,13 @@ def run(flags_obj):
...
@@ -201,12 +201,13 @@ def run(flags_obj):
num_classes
=
imagenet_main
.
NUM_CLASSES
,
num_classes
=
imagenet_main
.
NUM_CLASSES
,
dtype
=
dtype
)
dtype
=
dtype
)
model
.
compile
(
loss
=
'sparse_categorical_crossentropy'
,
model
.
compile
(
optimizer
=
optimizer
,
loss
=
'sparse_categorical_crossentropy'
,
metrics
=
([
'sparse_categorical_accuracy'
]
optimizer
=
optimizer
,
if
flags_obj
.
report_accuracy_metrics
else
None
),
metrics
=
([
'sparse_categorical_accuracy'
]
run_eagerly
=
flags_obj
.
run_eagerly
,
if
flags_obj
.
report_accuracy_metrics
else
None
),
run_distributed
=
flags_obj
.
force_v2_in_keras_compile
)
run_eagerly
=
flags_obj
.
run_eagerly
,
experimental_run_tf_function
=
flags_obj
.
force_v2_in_keras_compile
)
callbacks
=
keras_common
.
get_callbacks
(
callbacks
=
keras_common
.
get_callbacks
(
learning_rate_schedule
,
imagenet_main
.
NUM_IMAGES
[
'train'
])
learning_rate_schedule
,
imagenet_main
.
NUM_IMAGES
[
'train'
])
...
...
official/staging/shakespeare/shakespeare_main.py
View file @
a552e76a
...
@@ -162,13 +162,13 @@ def train_model(flags_obj, dataset, vocab_size, strategy, checkpoint_dir=None):
...
@@ -162,13 +162,13 @@ def train_model(flags_obj, dataset, vocab_size, strategy, checkpoint_dir=None):
with
strategy_scope
:
with
strategy_scope
:
model
=
build_model
(
vocab_size
=
vocab_size
,
batch_size
=
flags_obj
.
batch_size
)
model
=
build_model
(
vocab_size
=
vocab_size
,
batch_size
=
flags_obj
.
batch_size
)
model
.
compile
(
optimizer
=
tf
.
keras
.
optimizers
.
Adam
(),
model
.
compile
(
loss
=
tf
.
keras
.
losses
.
CategoricalCrossentropy
(),
optimizer
=
tf
.
keras
.
optimizers
.
Adam
(),
metrics
=
[
loss
=
tf
.
keras
.
losses
.
CategoricalCrossentropy
(),
tf
.
keras
.
metrics
.
Recall
(
top_k
=
1
,
name
=
'RecallAt1'
),
metrics
=
[
tf
.
keras
.
metrics
.
Recall
(
top_k
=
1
,
name
=
'RecallAt1'
),
tf
.
keras
.
metrics
.
Recall
(
top_k
=
5
,
name
=
'RecallAt5'
)],
tf
.
keras
.
metrics
.
Recall
(
top_k
=
5
,
name
=
'RecallAt5'
)],
run_eagerly
=
flags_obj
.
run_eagerly
,
run_eagerly
=
flags_obj
.
run_eagerly
,
run_distributed
=
flags_obj
.
force_v2_in_keras_compile
)
experimental_run_tf_function
=
flags_obj
.
force_v2_in_keras_compile
)
callbacks
=
[]
callbacks
=
[]
if
checkpoint_dir
:
if
checkpoint_dir
:
...
...
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