MCPcopy Create free account
hub / github.com/apple/axlearn / output_shape

Method output_shape

axlearn/common/layers.py:822–836  ·  view source on GitHub ↗
(self, *, input_shape: Sequence[Optional[int]])

Source from the content-addressed store, hash-verified

820 cfg = self.config
821 if len(input_shape) != 4:
822 raise ValueError(f"We expect len(input_shape) = 4, but got {len(input_shape)}.")
823 input_height, input_width = input_shape[1:3]
824
825 if input_height is not None:
826 output_height = max(input_height - cfg.window[0], 0) // cfg.strides[0] + 1
827 else:
828 output_height = None
829 if input_width is not None:
830 output_width = max(input_width - cfg.window[1], 0) // cfg.strides[1] + 1
831 else:
832 output_width = None
833 return [input_shape[0], output_height, output_width, input_shape[3]]
834
835
836class Embedding(BaseLayer):
837 """Implements an embedding lookup function.
838
839 Batched map for int in [0, <num_embeddings>) -> <dim> float vector.

Calls

no outgoing calls