# tff.learning.models.ModelWeights

<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) |

A container for the trainable and non-trainable variables of a `Model`.

    tff.learning.models.ModelWeights(
        trainable, non_trainable
    )

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Building Your Own Federated Learning Algorithm](https://www.tensorflow.org/federated/tutorials/building_your_own_federated_learning_algorithm) - [Composing Learning Algorithms](https://www.tensorflow.org/federated/tutorials/composing_learning_algorithms) - [Federated Learning for Text Generation](https://www.tensorflow.org/federated/tutorials/federated_learning_for_text_generation) - [Random noise generation in TFF](https://www.tensorflow.org/federated/tutorials/random_noise_generation) |

Note this does not include the model's local variables.

It may also be used to hold other values that are parallel to these variables,
e.g., tensors corresponding to variable values, or updates to model variables.

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `trainable` | A `namedtuple` alias for field number 0 |
| `non_trainable` | A `namedtuple` alias for field number 1 |

<br />

## Methods

### `assign_weights_to`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    assign_weights_to(
        model: Union[https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/VariableModel, tf.keras.Model]
    ) -> None

Assign these TFF model weights to the weights of a model.

<br />

<br />

<br />

| Args ||
|---|---|
| `model` | A [`tf.keras.Model`](https://www.tensorflow.org/api_docs/python/tf/keras/Model) or [`tff.learning.models.VariableModel`](https://www.tensorflow.org/federated/api_docs/python/tff/learning/models/VariableModel) instance to assign the weights to. |

<br />

### `convert_variables_to_arrays`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    convert_variables_to_arrays() -> 'ModelWeights'

Converts any internal [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable)s to numpy arrays.

### `from_model`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    @classmethod
    from_model(
        model
    )

### `from_tff_result`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    @classmethod
    from_tff_result(
        struct
    )