# tf_agents.trajectories.from_transition

<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#L614-L647) |

Returns a `Trajectory` given transitions.

#### View aliases


**Main aliases**

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

<br />

    tf_agents.trajectories.from_transition(
        time_step: https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/TimeStep,
        action_step: https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/PolicyStep,
        next_time_step: https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/TimeStep
    ) -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/Trajectory

### Used in the notebooks

| Used in the tutorials |
|---|
| - [DQN C51/Rainbow](https://www.tensorflow.org/agents/tutorials/9_c51_tutorial) |

`from_transition` is used by a driver to convert sequence of transitions into
a `Trajectory` for efficient storage. Then an agent (e.g.
[`ppo_agent.PPOAgent`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/agents/PPOAgent)) converts it back to transitions by invoking
`to_transition`.

Note that this method does not add a time dimension to the Tensors in the
resulting `Trajectory`. This means that if your transitions don't already
include a time dimension, the `Trajectory` cannot be passed to
`agent.train()`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `time_step` | A [`time_step.TimeStep`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/TimeStep) representing the first step in a transition. |
| `action_step` | A [`policy_step.PolicyStep`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/PolicyStep) representing actions corresponding to observations from time_step. |
| `next_time_step` | A [`time_step.TimeStep`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/TimeStep) representing the second step in a transition. |

<br />