RandomNN#

class sdm.prior.RandomNN(num_layers: HP[int] | int, hidden_channels: HP[int] | int, activation: Activation, linear: RandomLinear | None = None)#

Bases: RandomFunction

Apply a random neural network.

Parameters:
  • num_layers (HP[int] | int) – Number of linear layers.

  • hidden_channels (HP[int] | int) – Hidden width.

  • activation (Activation) – Activation applied between layers and, by random choice, before the first and after the last layer.

  • linear (RandomLinear | None) – Random linear function of each layer. Defaults to RandomLinear.

forward(x: Tensor, out_channels: int, generator: Generator | None = None) → Tensor#

Apply a sampled function to every row of x.

Parameters:
  • x (Tensor) – Input values with shape [R, H] for rows and channels.

  • out_channels (int) – Number of output channels.

  • generator (Generator | None) – Pseudorandom generator.

Returns:

Node values with shape [R, out_channels].

Return type:

Tensor