kd.typing.Shape

kd.typing.Shape#

class kauldron.typing.Shape(spec_str: str)[source]

Bases: tuple

Helper to construct concrete shape tuples from shape-specs.

Example: .. code-block:

@typchecked
def foo(x: Float["*b h w c"], y: Float["h w c"]):
  isinstance(x, Float["h w"])
  print(Shape("h w/2 c+1"))

foo(np.zeros((7, 32, 32, 3)))  # prints (32, 16, 4)