# Module: tff.learning.models

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

Libraries for working with models in federated learning algorithms.

## Classes

[`class BatchOutput`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/BatchOutput): A structure that holds the output of a [`tff.learning.models.VariableModel`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/VariableModel).

[`class FunctionalModel`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/FunctionalModel): A model that parameterizes forward pass by model weights.

[`class ModelWeights`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/ModelWeights): A container for the trainable and non-trainable variables of a `Model`.

[`class ReconstructionModel`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/ReconstructionModel): Represents a reconstruction model for use in Tensorflow Federated.

[`class VariableModel`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/VariableModel): Represents a variable-based model for use in TensorFlow Federated.

## Functions

[`from_keras_model(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/from_keras_model)

[`functional_model_from_keras(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/functional_model_from_keras): Converts a [`tf.keras.Model`](https://www.tensorflow.org/api_docs/python/tf/keras/Model) to a [`tff.learning.models.FunctionalModel`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/FunctionalModel).

[`load(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/load): Deserializes a TensorFlow SavedModel at `path` to a [`tff.learning.models.VariableModel`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/VariableModel).

[`load_functional_model(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/load_functional_model): Deserializes a TensorFlow SavedModel at `path` to a functional model.

[`model_from_functional(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/model_from_functional): Converts a `FunctionalModel` to a [`tff.learning.models.VariableModel`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/VariableModel).

[`save(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/save): Serializes `model` as a TensorFlow SavedModel to `path`.

[`save_functional_model(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/save_functional_model): Serializes a `FunctionalModel` as a `tf.SavedModel` to `path`.

[`weights_type_from_model(...)`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/weights_type_from_model): Creates a [`tff.Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type) from a [`tff.learning.models.VariableModel`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/VariableModel) or callable that constructs a model.

## Type Aliases

[`ReconstructionDatasetSplitFn`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/ReconstructionDatasetSplitFn)