alpine.models package#
Subpackages#
Submodules#
alpine.models.ffn module#
alpine.models.hashgrids module#
alpine.models.siren module#
- class alpine.models.siren.Siren#
Bases:
AlpineBaseModule
- __init__(in_features, hidden_features, hidden_layers, out_features, outermost_linear=True, omegas=[30.0], bias=True)#
Implements the Siren INR [Sitzmann et al., 2020] .
- Parameters:
in_features (int) – number of input features. For a coordinate based model, input the number of coordinate dims (2 for 2D, 3 for 3D)
hidden_features (int) – width of each layer in the INR. Number of neurons per layer.
hidden_layers (int) – Total number of hidden layers in the INR.
out_features (int) – number of output features. For a scalar or grayscale field, this is 1. For an RGB image, this field is 3.
outermost_linear (bool, optional) – Ensures that the last layer is a linear layer with no activation. Defaults to True.
omegas (list[float], optional) – Controls the bandwidth of each layer of the siren. Defaults to [30.0].
bias (bool, optional) – Sets bias for each layer in the INR. Defaults to True.
- forward(coords, return_features=False)#
Compute the forward pass of the Siren model.
- Parameters:
coords (torch.Tensor) – Input coordinates or features to the model of shape \(b \times \cdots \times d\) where b is batch and d is the number of input features.
return_features (bool, optional) – Set flag to True to return intermediate layer features along with computed output. Defaults to False.
- Returns:
Returns a dict with keys: output, features. The output key contains the output of the model. The features key contains the intermediate features of the model.
- Return type:
dict
- forward_w_features(coords)#
Compute the forward pass of the Siren model and return intermediate features.
- Parameters:
coords (torch.Tensor) – Input coordinates or features to the model of shape $b imes * imes d$
- Returns:
Returns a dict with keys: output, features. The output key contains the output of the model. The features key contains the intermediate features of the model.
- Return type:
dict
- load_weights(weights)#
- alpine.models.siren.get_linear_layer(in_features, out_features, omega=30.0, bias=True, is_first=False, is_last=False)#