xnn.common.models.multilinear.MultilinearBlock#

class xnn.common.models.multilinear.MultilinearBlock[source]#

Bases: object

Interface of a block for multilinear().

value(ops, only) evaluates the block; adjoints(g, ops, needs, only) returns one gradient per operand (None where needs is false). With only = i both run over the terms that contain operand i (all terms for only = -1). second() derives the derivatives of the adjoints from them; a block may override it to share work.

second(g, ops, cots, want_g, wants)[source]#

The gradients of <cots, adjoints(g, ops)> for g and the operands.

Parameters:
Return type:

Tuple[Tensor | None, List[Tensor | None]]