scimba_torch.neural_nets.coordinates_based_nets.siren

Siren architecture implementation.

Classes

SirenLayer(in_size, out_size[, w0, c, ...])

Class representing a Siren Layer.

SirenNet(in_size, out_size, **kwargs)

Class representing a Siren architecture with optional ResNet layers.

class SirenLayer(in_size, out_size, w0=1, c=6, is_first=False, use_bias=True)[source]

Bases: Module

Class representing a Siren Layer.

Parameters:
  • in_size (int) – Dimension of the inputs.

  • out_size (int) – Dimension of the outputs.

  • w0 (int) – Frequency parameter. Defaults to 1.

  • c (int) – Initialization parameter. Defaults to 6.

  • is_first (bool) – Whether this is the first layer. Defaults to False.

  • use_bias (bool) – Whether to use bias. Defaults to True.

in_size

Dimension of the inputs.

is_first

Whether this is the first layer.

out_size

Dimension of the outputs.

layer

The linear layer applied to the vector of features.

activation

The sine activation function.

init_(weight, bias, c, w0)[source]

Init the weights of the layer using the specific Siren initialization.

Parameters:
  • weight (Tensor) – The weight of the layer to initialize.

  • bias (Tensor) – The bias of the layer to initialize.

  • c (int) – A parameter for the weight initialization.

  • w0 (int) – The frequency of the sinus activation function.

forward(x)[source]

Apply the network to the inputs.

Parameters:

x (Tensor) – Input tensor.

Return type:

Tensor

Returns:

The result of the layer.

class SirenNet(in_size, out_size, **kwargs)[source]

Bases: ScimbaModule

Class representing a Siren architecture with optional ResNet layers.

Parameters:
  • in_size (int) – dimension of inputs

  • out_size (int) – dimension of outputs

  • **kwargs

    Additional keyword arguments:

    • w (int): frequency for the internal layers’ activation functions

    • w0 (int): frequency for the first layer’s activation function

    • layer_sizes (list[int]): list of the size for each layer

    • use_res_net (bool, default=False): whether to use a ResNet architecture

layers

list of Siren layers, potentially with residual connections

forward(x, with_last_layer=True)[source]

Apply the network to the inputs x.

Parameters:
  • x (Tensor) – input tensor

  • with_last_layer (bool) – Whether to apply the final output layer

Return type:

Tensor

Returns:

the result of the network