OccupancyNetworkDecoder<T>
Layers · AiDotNet.NeuralNetworks.Layers
Implements the decoder of an Occupancy Network (Mescheder et al., CVPR 2019,
arXiv:1812.03828): the fully-connected, conditional-normalization ResNet that
maps a queried 3D point p ∈ ℝ³ to an occupancy probability,
conditioned on a latent code c describing the shape.
Inheritance: LayerBase<T> → OccupancyNetworkDecoder<T>
Implements: IShapeContract
How It Works
Architecture (paper §4.1 / supplementary “Network Architecture”, the
DecoderCBN module). A linear point embedding feeds a stack of
pre-activation Conditional-ResNet blocks, then a final CBN → ReLU → linear
produces the occupancy logit:
where Conditional Normalization is
CN(x, c) = γ(c) ⊙ Norm(x) + β(c) and γ(c), β(c)
are linear projections of the latent code (the paper predicts the
normalization affine from the condition rather than learning it
unconditionally — this is what makes the block “conditional”).
Layer- vs Batch-Normalization. The paper’s Norm is Batch
Normalization, which is well-defined because it trains on large point
batches (T ≈ 2048 sampled points per shape). This model’s public surface
evaluates a single point at a time (batch = 1), where batch statistics
collapse (variance = 0, so BatchNorm zeroes the signal and starves the
gradient — the exact failure that makes a single-point CBN untrainable).
We therefore normalize per-sample across the feature axis (Layer
Normalization, Ba et al. 2016) instead of across the batch. The conditional
affine, pre-activation residual structure, block count, and latent
conditioning are unchanged — only the normalization axis differs, so the
architecture stays faithful while remaining well-defined at any batch size.
The residual skips carry the input magnitude past each (scale-invariant)
normalization, so the decoder still responds to input scaling.
Conditioning without an encoder (auto-decoder). The paper produces
c from an encoder over an observation (image / point cloud). When the
model has no observation to encode — as here, where the public surface is
just point → occupancy — the standard substitute is a learnable latent code
(the DeepSDF auto-decoder of Park et al. 2019): a single trained vector that
the decoder conditions on, so the network represents one occupancy field.
The code is realized as a DenseLayer driven by a constant
input of 1, so it trains through the same tape/optimizer path as every
other parameter (no bespoke trainable-tensor wiring).
Backward is handled by the gradient tape: every operation here is either an
Engine op or a sub-layer Forward, so TrainWithTape records
the full graph and there is no hand-written backward to drift out of sync.
Constructors
| Constructor | Summary |
|---|---|
OccupancyNetworkDecoder(int pointDim, int hidden, int latentDim, int numBlocks) |
Builds an Occupancy Network decoder. |
Properties
| Property | Summary |
|---|---|
bool SupportsTraining { get; } |
|
int Hidden { get; } |
Hidden width of the decoder’s fully-connected ResNet trunk. |
int LatentDim { get; } |
Dimensionality of the (learnable) latent conditioning code. |
int NumBlocks { get; } |
Number of Conditional-ResNet blocks in the trunk. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, string> GetParameterRoles() |
Returns parameter roles for per-role optimizer configuration (e.g., weight decay exemption for biases). |
IReadOnlyList<ILayer<T>> GetSubLayers() |
|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
IReadOnlyList<Tensor<T>> GetTrainableParameters() |
Returns all trainable parameter tensors marked with [TrainableParameter]. |
void ResetState() |
|
void SetTrainableParameters(IReadOnlyList<Tensor<T>> parameters) |
Replaces trainable parameter tensors (e.g., with ParameterBuffer views). |
void SetTrainingMode(bool isTraining) |
|
void UpdateParameters(T learningRate) |
|
void ZeroGrad() |
Clears all gradient fields discovered by convention ({paramName}Gradient). |