Aligns the time dimension of :obj:`x` with :obj:`length`.
(x, length)
| 21 | |
| 22 | |
| 23 | def 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 | |
| 32 | def pad_with_identity(x, sequence_length, max_sequence_length, identity_values=0, maxlen=None): |
nothing calls this directly
no test coverage detected