zero.nn.Lambda

class zero.nn.Lambda(fn)[source]

A parameters-free module for wrapping callables.

Examples

assert zero.nn.Lambda(lambda: 0)() == 0
assert zero.nn.Lambda(lambda x: x)(1) == 1
assert zero.nn.Lambda(lambda x, y, z: x + y + z)(1, 2, z=3) == 6
Parameters

fn (Callable) –

__init__(fn)[source]

Initialize self.

Parameters

fn (Callable) –

forward(*args, **kwargs)[source]

Perform the forward pass.