Skip to content

Documentation discrepancy between Keras and Tensorflow Distributed strategy guides: should fit be inside or outside strategy scope? #2007

Open
@seanv507

Description

@seanv507

Issue Type

Documentation Bug

Source

source

Keras Version

current master branch

Custom Code

No

OS Platform and Distribution

No response

Python version

No response

GPU model and memory

No response

Current Behavior?

Documentation discrepancy.

https://github.com/keras-team/keras-io/blob/9c3b9b7b1f0ffc20f13833b067925d757b961a42/guides/distributed_training_with_tensorflow.py#L82C1-L86C1

Use the strategy object to open a scope, and within this scope, create all the Keras
objects you need that contain variables. Typically, that means creating & compiling the
model
inside the distribution scope. In some cases, the first call to fit() may also
create variables, so it's a good idea to put your fit() call in the scope as well.

Similarly the code sample on that page has fit within the strategy scope.

https://www.tensorflow.org/guide/keras/distributed_training

Use the strategy object to open a scope, and within this scope, create all the Keras objects you need that contain variables. Typically, that means creating & compiling the model inside the distribution scope.

Similarly the code sample on that page has fit outside the strategy scope.

Standalone code to reproduce the issue or tutorial link

Documentation issue

Relevant log output

No response

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions