# tf_agents.bandits.multi_objective.multi_objective_scalarizer.LinearScalarizer

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/bandits/multi_objective/multi_objective_scalarizer.py#L210-L262) |

Scalarizes multple objectives by a linear combination.

Inherits From: [`Scalarizer`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/bandits/multi_objective/multi_objective_scalarizer/Scalarizer)

    tf_agents.bandits.multi_objective.multi_objective_scalarizer.LinearScalarizer(
        weights: Sequence[https://www.tensorflow.org/agents/api_docs/python/tf_agents/bandits/multi_objective/multi_objective_scalarizer/ScalarFloat],
        multi_objective_transform: Optional[Callable[[tf.Tensor], tf.Tensor]] = None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `weights` | A `Sequence` of weights for linearly combining the objectives. |
| `multi_objective_transform` | A `Optional` `Callable` that takes in a [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of multiple objective values and applies an arbitrary transform that returns a [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of transformed multiple objectives. This transform is applied before the linear scalarization. The transform should apply to each objective so that the shape of the multiobjectives and the transformed multiobjectives are equal. This is verified in _validate_scalarization_parameter_shape via **call**. |

<br />

## Methods

### `set_parameters`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/bandits/multi_objective/multi_objective_scalarizer.py#L249-L262)

    set_parameters(
        weights: tf.Tensor
    )

Set the scalarization parameter of the LinearScalarizer.

<br />

<br />

<br />

| Args ||
|---|---|
| `weights` | A a rank-2 [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of weights shaped as \[batch_size, self._num_of_objectives\], where `batch_size` should match the batch size of the `multi_objectives` passed to the scalarizer call. |

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | if the weights tensor is not rank-2, or has a last dimension size that does not match `self._num_of_objectives`. |

<br />

### `__call__`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/bandits/multi_objective/multi_objective_scalarizer.py#L135-L161)

    __call__(
        multi_objectives: tf.Tensor
    ) -> tf.Tensor

Returns a single reward by scalarizing multiple objectives.

<br />

<br />

<br />

| Args ||
|---|---|
| `multi_objectives` | A `Tensor` of shape \[batch_size, number_of_objectives\], where each column represents an objective. |

<br />

Returns: A `Tensor` of shape \[batch_size\] representing scalarized rewards.

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | if `multi_objectives.shape.rank != 2`. |
| `ValueError` | if `multi_objectives.shape.dims[1] != self._num_of_objectives`. |

<br />