UNet3D<T>
Models & Types · AiDotNet.NeuralNetworks
Represents a 3D U-Net neural network for volumetric semantic segmentation.
Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → VolumetricModelLayoutBase<T> → UNet3D<T>
For Beginners
A 3D U-Net is like an intelligent 3D scanner that can identify and label every single voxel (3D pixel) in a 3D volume.
Think of it like this:
- The encoder (left side of “U”) looks at the big picture by progressively zooming out
- The decoder (right side of “U”) zooms back in to produce detailed predictions
- Skip connections (horizontal lines in “U”) preserve fine details from encoder to decoder
This is useful for:
- Medical imaging: Finding organs or tumors in CT/MRI scans
- 3D scene understanding: Segmenting objects in point clouds
- Part segmentation: Identifying different parts of 3D shapes
The “U” shape comes from the symmetric encoder-decoder design with skip connections.
How It Works
A 3D U-Net extends the classic U-Net architecture to three dimensions for processing volumetric data. It uses an encoder-decoder structure with skip connections to produce dense, per-voxel predictions while preserving both local details and global context.
Example
var architecture = new NeuralNetworkArchitecture<float>(inputFeatures: 8, outputSize: 4);
var volume = Tensor<float>.CreateRandom(new[] { 1, 1, 64, 64, 64 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
.ConfigureModel(new UNet3D<float>(architecture))
.Build(trainX, trainY);
var segmented = result.Predict(volume);
Constructors
| Constructor | Summary |
|---|---|
UNet3D() |
Initializes a new instance with default architecture settings. |
UNet3D(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, UNet3DOptions options) |
Initializes the model from an already-resolved options instance. |
Properties
| Property | Summary |
|---|---|
int BaseFilters { get; set; } |
Gets the base number of filters in the first encoder block. |
int NumClasses { get; set; } |
Gets the number of output classes (segmentation categories). |
int NumEncoderBlocks { get; set; } |
Gets the number of encoder blocks in the network. |
int VoxelResolution { get; set; } |
Gets the voxel grid resolution used by this network. |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
Gets metadata about this model for serialization and inspection. |
Tensor<T> Forward(Tensor<T> input) |
Performs a forward pass through the network. |
Tensor<T> ForwardForTraining(Tensor<T> input) |
Training must take the same skip path as inference. |