returnn.tf.frontend_layers.prev_tensor_ref

prev tensor ref for loop, i.e. RecLayer, specifically “prev:…” layer references

class returnn.tf.frontend_layers.prev_tensor_ref.PrevTensorRef(*, name_ctx: Layer, cur_layer_name_ctx: Layer, data: Tensor)[source]

Refers to a layer from the previous loop iteration.

Parameters:
  • name

  • dims – the shape, where each dimension is described by a Dim.

  • dtype – e.g. “float32” or “int64”

  • sparse_dim – when the values are indices into some dimension, this is the dimension. You can also interpret the whole tensor as a sparse representation of a dense one-hot tensor, where this sparse_dim becomes the additional dense dimension.

  • raw_tensor – the raw tensor, e.g. numpy array, TF tensor, or PyTorch tensor

  • version

    behavior version just for Tensor. If not specified, and dims is None (old code), it uses version 1. - v1: the old behavior of Data. Specifically, time_dim_axis and feature_dim_axis are used

    and automatically inferred when not specified.

    • v2: time_dim_axis, feature_dim_axis are None by default.

  • kwargs – see _handle_extra_kwargs(), infer_dim_tags()

classmethod get_prev_ref(*, cur_layer_name_ctx: Layer, initial: Tensor) PrevTensorRef[source]

Create prev ref.

assign_new_cur_tensor_name_ctx(cur_tensor_name_ctx: Layer)[source]

Changes self.name_ctx to new name_ctx.

name: str[source]
dtype: str[source]
sparse_dim: Dim | None[source]
version: int[source]