fvdb.nn

fvdb.nn is a collection of neural network layers to build sparse neural networks.

class fvdb.nn.VDBTensor(grid: GridBatch, data: JaggedTensor, kmap: SparseConvPackInfo | None = None)[source]

A VDBTensor is a thin wrapper around a GridBatch and its corresponding feature JaggedTensor, conceptually denoting a batch of sparse tensors along with its topology. It works as the input and output arguments of fvdb’s neural network layers. One can simply construct a VDBTensor from a GridBatch and a JaggedTensor, or from a dense tensor using from_dense().

class fvdb.nn.MaxPool(kernel_size: int | List[int], stride: int | List[int] | None = None)[source]

Applies a 3D max pooling over an input signal.

Parameters:
  • kernel_size – the size of the window to take a max over

  • stride – the stride of the window. Default value is kernel_size

Note

For target voxels that are not covered by any source voxels, the output feature will be set to zero.

class fvdb.nn.AvgPool(kernel_size: int | List[int], stride: int | List[int] | None = None)[source]

Applies a 3D average pooling over an input signal.

Parameters:
  • kernel_size – the size of the window to take average over

  • stride – the stride of the window. Default value is kernel_size

class fvdb.nn.UpsamplingNearest(scale_factor: int | List[int])[source]

Upsamples the input by a given scale factor using nearest upsampling.

Parameters:

scale_factor – the upsampling factor

class fvdb.nn.FillFromGrid(default_value: float = 0.0)[source]

Fill the content of input vdb-tensor to another grid.

Parameters:

default_value – the default value to fill in the new grid.

class fvdb.nn.SparseConv3d(in_channels: int, out_channels: int, kernel_size: int | Sequence = 3, stride: int | Sequence = 1, bias: bool = True, transposed: bool = False)[source]

Applies a 3D convolution over an input signal composed of several input planes, by performing a sparse convolution on the underlying VDB grid.

Parameters:
  • in_channels – number of channels in the input tensor

  • out_channels – number of channels produced by the convolution

  • kernel_size – size of the convolving kernel

  • stride – stride of the convolution. Default value is 1

  • bias – if True, adds a learnable bias to the output. Default: True

  • transposed – if True, uses a transposed convolution operator

class fvdb.nn.GroupNorm(num_groups: int, num_channels: int, eps: float = 1e-05, affine: bool = True, device=None, dtype=None)[source]

Applies Group Normalization over a VDBTensor. See GroupNorm for detailed information.

class fvdb.nn.Linear(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None)[source]

Applies a linear transformation to the incoming data: \(y = xA^T + b\).

class fvdb.nn.ReLU(inplace: bool = False)[source]

Applies the rectified linear unit function element-wise: \(\text{ReLU}(x) = (x)^+ = \max(0, x)\)

class fvdb.nn.LeakyReLU(negative_slope: float = 0.01, inplace: bool = False)[source]

Applies the element-wise function: \(\text{LeakyReLU}(x) = \max(0, x) + \text{negative\_slope} * \min(0, x)\)

class fvdb.nn.SELU(inplace: bool = False)[source]

Applies element-wise, \(\text{SELU}(x) = \lambda \left\{ \begin{array}{lr} x, & \text{if } x > 0 \\ \text{negative\_slope} \times e^x - \text{negative\_slope}, & \text{otherwise } \end{array} \right.\)

class fvdb.nn.SiLU(inplace: bool = False)[source]

Applies element-wise, \(\text{SiLU}(x) = x * \sigma(x)\), where \(\sigma(x)\) is the sigmoid function.

class fvdb.nn.Tanh(*args, **kwargs)[source]

Applies element-wise, \(\text{Tanh}(x) = \tanh(x) = \frac{e^x - e^{-x}} {e^x + e^{-x}}\)

class fvdb.nn.Sigmoid(*args, **kwargs)[source]

Applies element-wise, \(\text{Sigmoid}(x) = \frac{1}{1 + \exp(-x)}\)

class fvdb.nn.Dropout(p: float = 0.5, inplace: bool = False)[source]

During training, randomly zeroes some of the elements of the input tensor with probability p using samples from a Bernoulli distribution. The elements to zero are randomized on every forward call.