From 3784a39af69c8db816cee85598a4774cfc2accca Mon Sep 17 00:00:00 2001 From: Albert Zeyer Date: Wed, 13 Sep 2023 18:02:07 +0200 Subject: [PATCH] TF PositionalEncodingLayer better, small fix --- returnn/tf/layers/rec.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/returnn/tf/layers/rec.py b/returnn/tf/layers/rec.py index 957aec43b2..56752bdaf8 100644 --- a/returnn/tf/layers/rec.py +++ b/returnn/tf/layers/rec.py @@ -8309,10 +8309,11 @@ def __init__(self, axis=NotSpecified, add_to_input=False, constant=-1, offset=No signal = get_positional_encoding(num_channels=self.output.dim, position=position) else: # single step if constant > -1: - position = tf.convert_to_tensor([constant]) + position = tf.convert_to_tensor([constant]) # (1,) else: position = self._rec_previous_layer.rec_vars_outputs["position"] + 1 self.rec_vars_outputs["position"] = position + position = tf.expand_dims(position, axis=0) # (1,) if offset_data: position += offset_data.placeholder # (batch,) signal = get_positional_encoding( @@ -8337,7 +8338,7 @@ def transform_config_dict(cls, d, network, get_layer): """ if d.get("from", None) is None: if network.is_inside_rec_layer(): - d["from"] = [] + d["from"] = [":i"] else: d["from"] = ["data"] super(PositionalEncodingLayer, cls).transform_config_dict(d, network=network, get_layer=get_layer)