# tf_agents.bandits.policies.constraints.InputNetworkConstraint

<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/policies/constraints.py#L499-L554) |

Class for representing a constraint using an input network.

Inherits From: [`BaseConstraint`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/bandits/policies/constraints/BaseConstraint)

    tf_agents.bandits.policies.constraints.InputNetworkConstraint(
        time_step_spec: https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types#TimeStep,
        action_spec: https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types#BoundedTensorSpec,
        input_network: Optional[https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types#Network] = None,
        name: Optional[Text] = 'InputNetworkConstraint'
    )

This constraint class uses an input network to compute the action feasibility.
It assumes that the input network is already trained and it can be provided
at construction time or later using the set_network() function.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `time_step_spec` | A `TimeStep` spec of the expected time_steps. |
| `action_spec` | A nest of `BoundedTensorSpec` representing the actions. |
| `input_network` | An instance of `tf_agents.network.Network` used to provide estimates of action feasibility. |
| `name` | Python str name of this agent. All variables in this module will fall under that name. Defaults to the class name. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `network` | <br /> <br /> |

<br />

## Methods

### `compute_loss`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/bandits/policies/constraints.py#L540-L549)

    compute_loss(
        observations: https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/NestedTensor,
        actions: https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/NestedTensor,
        rewards: https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/Tensor,
        weights: Optional[types.TensorOrArray] = None,
        training: bool = False
    ) -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/Tensor

### `__call__`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/bandits/policies/constraints.py#L552-L554)

    @abc.abstractmethod
    __call__(
        observation, actions=None
    )

Returns the probability of input actions being feasible.