Constructs an Estimator instance from given keras model.

Used in the notebooks

Used in the guide Used in the tutorials

If you use infrastructure or other tooling that relies on Estimators, you can still build a Keras model and use model_to_estimator to convert the Keras model to an Estimator for use with downstream systems.

For usage example, please see: Creating estimators from Keras Models.

Sample Weights:

Estimators returned by model_to_estimator are configured so that they can handle sample weights (similar to, y, sample_weights)).

To pass sample weights when training or evaluating the Estimator, the first item returned by the input function should be a dictionary with keys features and sample_weights. Example below:

keras_model = tf.keras.Model(...)

estimator = tf.keras.estimator.model_to_estimator(keras_model)

def input_fn():
  return dataset_ops.Dataset.from_tensors(
      ({'features': features, 'sample_weights': sample_weights},

estimator.train(input_fn, steps=1)

Example with customized export signature:

inputs = {'a': tf.keras.Input(..., name='a'),
          'b': tf.keras.Input(..., name='b')}
outputs = {'c':