MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / align_in_time

Function align_in_time

examples/tensorflow/decoder/utils/reducer.py:23–29  ·  view source on GitHub ↗

Aligns the time dimension of :obj:`x` with :obj:`length`.

(x, length)

Source from the content-addressed store, hash-verified

21
22
23def align_in_time(x, length):
24 """Aligns the time dimension of :obj:`x` with :obj:`length`."""
25 time_dim = tf.shape(x)[1]
26 return tf.cond(
27 tf.less(time_dim, length),
28 true_fn=lambda: pad_in_time(x, length - time_dim),
29 false_fn=lambda: x[:, :length])
30
31
32def pad_with_identity(x, sequence_length, max_sequence_length, identity_values=0, maxlen=None):

Callers

nothing calls this directly

Calls 1

pad_in_timeFunction · 0.70

Tested by

no test coverage detected