UpsamplingLayer<T>

Layers · AiDotNet.NeuralNetworks.Layers

Represents an upsampling layer that increases the spatial dimensions of input tensors using nearest-neighbor interpolation.

Inheritance: LayerBase<T> → UpsamplingLayer<T>

Implements: IShapeContract

For Beginners

This layer makes images or feature maps larger by simply repeating pixels.

Think of it like zooming in on a digital image:

  • When you zoom in on a pixelated image, each original pixel becomes a larger square
  • This layer does the same thing to feature maps inside the neural network
  • It’s like stretching an image without adding any new information

For example, with a scale factor of 2:

  • A 4×4 image becomes an 8×8 image
  • Each pixel in the original image is copied to a 2×2 block in the output
  • This creates a larger image that preserves the original content but with more pixels

This is useful for tasks like image generation or upscaling, where you need to increase the resolution of features that the network has processed.

How It Works

An upsampling layer increases the spatial dimensions (height and width) of input tensors by repeating values from the input to create a larger output. This implementation uses nearest-neighbor interpolation, which repeats each value in the input tensor multiple times based on the scale factor to create the upsampled output.

Constructors

Constructor Summary
UpsamplingLayer(int scaleFactor) Initializes a new instance of the UpsamplingLayer class.

Properties

Property Summary
bool SupportsTraining { get; } Gets a value indicating whether this layer supports training.

Methods

Method Summary
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank)
void ResetState() Resets the internal state of the layer.