frame_step = 1
result = shape_ops.frame(signal, frame_length, frame_step,
pad_end=True, pad_value=99, axis=1)
- self.assertEqual([1, None, None, 3, 4], result.shape.as_list())
+ self.assertEqual([1, 2, None, 3, 4], result.shape.as_list())
result = shape_ops.frame(signal, frame_length, frame_step,
pad_end=False, axis=1)
outer_dimensions = signal_shape[:axis]
inner_dimensions = signal_shape[axis:][1:]
if signal_shape and frame_axis is not None:
- if frame_step and frame_length is not None:
- if pad_end:
- # Double negative is so that we round up.
- num_frames = -(-frame_axis // frame_step)
- else:
- num_frames = (frame_axis - frame_length + frame_step) // frame_step
- num_frames = max(0, num_frames)
+ if frame_step is not None and pad_end:
+ # Double negative is so that we round up.
+ num_frames = max(0, -(-frame_axis // frame_step))
+ elif frame_step is not None and frame_length is not None:
+ assert not pad_end
+ num_frames = max(
+ 0, (frame_axis - frame_length + frame_step) // frame_step)
return outer_dimensions + [num_frames, frame_length] + inner_dimensions