@@ -445,6 +445,7 @@ def compile(self,
445445 loss_weights = None ,
446446 weighted_metrics = None ,
447447 run_eagerly = None ,
448+ steps_per_execution = None ,
448449 ** kwargs ):
449450 """Configures the model for training.
450451
@@ -496,24 +497,32 @@ def compile(self,
496497 logic will not be wrapped in a `tf.function`. Recommended to leave
497498 this as `None` unless your `Model` cannot be run inside a
498499 `tf.function`.
499- **kwargs: Any additional arguments. Supported arguments:
500- - `experimental_steps_per_execution`: Int. The number of batches to
501- run during each `tf.function` call. Running multiple batches
502- inside a single `tf.function` call can greatly improve performance
503- on TPUs or small models with a large Python overhead. Note that if
504- this value is set to `N`, `Callback.on_batch` methods will only be
505- called every `N` batches. This currently defaults to `1`. At most,
506- one full epoch will be run each execution. If a number larger than
507- the size of the epoch is passed, the execution will be truncated
508- to the size of the epoch.
509- - `sample_weight_mode` for backward compatibility.
500+ steps_per_execution: Int. Defaults to 1. The number of batches to
501+ run during each `tf.function` call. Running multiple batches
502+ inside a single `tf.function` call can greatly improve performance
503+ on TPUs or small models with a large Python overhead.
504+ At most, one full epoch will be run each
505+ execution. If a number larger than the size of the epoch is passed,
506+ the execution will be truncated to the size of the epoch.
507+ Note that if `steps_per_execution` is set to `N`,
508+ `Callback.on_batch_begin` and `Callback.on_batch_end` methods
509+ will only be called every `N` batches
510+ (i.e. before/after each `tf.function` execution).
511+ **kwargs: Arguments supported for backwards compatibility only.
510512
511513 Raises:
512514 ValueError: In case of invalid arguments for
513515 `optimizer`, `loss` or `metrics`.
514516 """
515517 base_layer .keras_api_gauge .get_cell ('compile' ).set (True )
516518 with self .distribute_strategy .scope ():
519+ if 'experimental_steps_per_execution' in kwargs :
520+ logging .warn ('The argument `steps_per_execution` is no longer '
521+ 'experimental. Pass `steps_per_execution` instead of '
522+ '`experimental_steps_per_execution`.' )
523+ if not steps_per_execution :
524+ steps_per_execution = kwargs .pop ('experimental_steps_per_execution' )
525+
517526 self ._validate_compile (optimizer , metrics , ** kwargs )
518527 self ._run_eagerly = run_eagerly
519528
@@ -523,9 +532,7 @@ def compile(self,
523532 self .compiled_metrics = compile_utils .MetricsContainer (
524533 metrics , weighted_metrics , output_names = self .output_names )
525534
526- experimental_steps_per_execution = kwargs .pop (
527- 'experimental_steps_per_execution' , 1 )
528- self ._configure_steps_per_execution (experimental_steps_per_execution )
535+ self ._configure_steps_per_execution (steps_per_execution or 1 )
529536
530537 # Initializes attrs that are reset each time `compile` is called.
531538 self ._reset_compile_cache ()
@@ -2460,9 +2467,7 @@ def _validate_compile(self, optimizer, metrics, **kwargs):
24602467 if kwargs .pop ('target_tensors' , None ) is not None :
24612468 raise ValueError (
24622469 'target_tensors argument is not supported when executing eagerly.' )
2463- invalid_kwargs = set (kwargs ) - {
2464- 'experimental_steps_per_execution' , 'sample_weight_mode'
2465- }
2470+ invalid_kwargs = set (kwargs ) - {'sample_weight_mode' }
24662471 if invalid_kwargs :
24672472 raise TypeError ('Invalid keyword argument(s) in `compile`: %s' %
24682473 (invalid_kwargs ,))
0 commit comments