# tf_agents.trajectories.Trajectory

<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/trajectories/trajectory.py#L36-L124) |

A tuple that represents a trajectory.

#### View aliases


**Main aliases**

[`tf_agents.trajectories.trajectory.Trajectory`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/Trajectory)

<br />

    tf_agents.trajectories.Trajectory(
        step_type,
        observation,
        action,
        policy_info,
        next_step_type,
        reward,
        discount
    )

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Tutorial on Multi Armed Bandits in TF-Agents](https://www.tensorflow.org/agents/tutorials/bandits_tutorial) - [Tutorial on Ranking in TF-Agents](https://www.tensorflow.org/agents/tutorials/ranking_tutorial) |

A `Trajectory` represents a sequence of aligned time steps. It captures the
observation, step_type from current time step with the computed action
and policy_info. Discount, reward and next_step_type come from the next
time step.

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `step_type` | A `StepType`. |
| `observation` | An array (tensor), or a nested dict, list or tuple of arrays (tensors) that represents the observation. |
| `action` | An array/a tensor, or a nested dict, list or tuple of actions. This represents action generated according to the observation. |
| `policy_info` | An arbitrary nest that contains auxiliary information related to the action. Note that this does not include the policy/RNN state which was used to generate the action. |
| `next_step_type` | The `StepType` of the next time step. |
| `reward` | An array/a tensor, or a nested dict, list, or tuple of rewards. This represents the rewards and/or constraint satisfiability after performing the action in an environment. |
| `discount` | A scalar that representing the discount factor to multiply with future rewards. |

<br />

## Methods

### `is_boundary`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/trajectories/trajectory.py#L96-L99)

    is_boundary() -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/Bool

### `is_first`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/trajectories/trajectory.py#L76-L79)

    is_first() -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/Bool

### `is_last`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/trajectories/trajectory.py#L91-L94)

    is_last() -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/Bool

### `is_mid`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/trajectories/trajectory.py#L81-L89)

    is_mid() -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/Bool

### `replace`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/trajectories/trajectory.py#L101-L117)

    replace(
        **kwargs
    ) -> 'Trajectory'

Exposes as namedtuple._replace.

#### Usage:

      new_trajectory = trajectory.replace(policy_info=())

This returns a new trajectory with an empty policy_info.

<br />

<br />

<br />

| Args ||
|---|---|
| `**kwargs` | key/value pairs of fields in the trajectory. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A new `Trajectory`. ||

<br />