[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf_agents.trajectories.trajectory.from_episode\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/trajectories/trajectory.py#L491-L611) |\n\nCreate a Trajectory from tensors representing a single episode. \n\n tf_agents.trajectories.trajectory.from_episode(\n observation: ../../../tf_agents/typing/types/NestedSpecTensorOrArray,\n action: ../../../tf_agents/typing/types/NestedSpecTensorOrArray,\n policy_info: ../../../tf_agents/typing/types/NestedSpecTensorOrArray,\n reward: ../../../tf_agents/typing/types/NestedSpecTensorOrArray,\n discount: Optional[types.SpecTensorOrArray] = None\n ) -\u003e ../../../tf_agents/trajectories/Trajectory\n\nIf none of the inputs are tensors, then numpy arrays are generated instead.\n\nIf `discount` is not provided, the first entry in `reward` is used to estimate\n`T`: \n\n reward_0 = tf.nest.flatten(reward)[0]\n T = shape(reward_0)[0]\n\nIn this case, a `discount` of all ones having dtype `float32` is generated.\n| **Note:** all tensors/numpy arrays passed to this function have the same time dimension `T`. When the generated trajectory passes through `to_transition`, it will only return a `(time_steps, next_time_steps)` pair with `T - 1` in the time dimension, which means the reward at step T is dropped. So if the reward at step `T` is important, please make sure the episode passed to this function contains an additional step.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|-----------------------------------------------------------------------------|\n| `observation` | (possibly nested tuple of) `Tensor` or `np.ndarray`; all shaped `[T, ...]`. |\n| `action` | (possibly nested tuple of) `Tensor` or `np.ndarray`; all shaped `[T, ...]`. |\n| `policy_info` | (possibly nested tuple of) `Tensor` or `np.ndarray`; all shaped `[T, ...]`. |\n| `reward` | (possibly nested tuple of) `Tensor` or `np.ndarray`; all shaped `[T, ...]`. |\n| `discount` | A floating point vector `Tensor` or `np.ndarray`; shaped `[T]` (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| An instance of `Trajectory`. ||\n\n\u003cbr /\u003e"]]