MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _infer_frame_shape

Function _infer_frame_shape

tensorflow/python/ops/signal/shape_ops.py:29–52  ·  view source on GitHub ↗

Infers the shape of the return value of `frame`.

(signal, frame_length, frame_step, pad_end, axis)

Source from the content-addressed store, hash-verified

27
28
29def _infer_frame_shape(signal, frame_length, frame_step, pad_end, axis):
30 """Infers the shape of the return value of `frame`."""
31 frame_length = tensor_util.constant_value(frame_length)
32 frame_step = tensor_util.constant_value(frame_step)
33 axis = tensor_util.constant_value(axis)
34 if signal.shape.ndims is None:
35 return None
36 if axis is None:
37 return [None] * (signal.shape.ndims + 1)
38
39 signal_shape = signal.shape.as_list()
40 num_frames = None
41 frame_axis = signal_shape[axis]
42 outer_dimensions = signal_shape[:axis]
43 inner_dimensions = signal_shape[axis:][1:]
44 if signal_shape and frame_axis is not None:
45 if frame_step is not None and pad_end:
46 # Double negative is so that we round up.
47 num_frames = max(0, -(-frame_axis // frame_step))
48 elif frame_step is not None and frame_length is not None:
49 assert not pad_end
50 num_frames = max(
51 0, (frame_axis - frame_length + frame_step) // frame_step)
52 return outer_dimensions + [num_frames, frame_length] + inner_dimensions
53
54
55@tf_export("signal.frame")

Callers 1

frameFunction · 0.85

Calls 2

maxFunction · 0.50
as_listMethod · 0.45

Tested by

no test coverage detected