contract

Contents

contract#

penzai.nn.linear_and_affine.contract(names: str | Sequence[named_axes.AxisName], left: NamedArray, right: NamedArray) NamedArray[source]#

Contracts two named arrays along the given axis names.

Parameters:
  • names – The axis names to contract. Can also be a single string axis name.

  • left – The left-hand side of the contraction, as a NamedArray with only named axes.

  • right – The right-hand side of the contraction, as a NamedArray with only named axes.

Returns:

Result of the contraction, which will have all names present in either left or right, except for the names in names which will be contracted away.