UNetDiscriminator<T>

Layers · AiDotNet.NeuralNetworks.Layers

U-Net Discriminator as used in Real-ESRGAN for improved perceptual quality.

Inheritance: LayerBase<T> → UNetDiscriminator<T>

Implements: IShapeContract

For Beginners

The discriminator judges whether an image is real or fake.

Traditional discriminators output a single “real/fake” score for the whole image. U-Net discriminator outputs a “real/fake” prediction for EVERY PIXEL, which:

  • Provides more detailed feedback to the generator
  • Helps produce sharper details and textures
  • Enables better reconstruction of fine features

The U-Net architecture (encoder + decoder with skip connections) allows the discriminator to consider both local details and global context.

How It Works

This implements the U-Net discriminator from the Real-ESRGAN paper (Wang et al., 2021). Unlike traditional patch discriminators, U-Net discriminator provides pixel-level feedback which helps the generator produce finer details.

The architecture has an encoder-decoder structure:

Reference: Wang et al., “Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data”, ICCV 2021. https://arxiv.org/abs/2107.10833

Constructors

Constructor Summary
UNetDiscriminator(int numChannels, int numBlocks) Initializes a new U-Net discriminator.

Properties

Property Summary
bool SupportsTraining { get; }
int NumBlocks { get; } Gets the number of encoder/decoder blocks.
int NumChannels { get; } Gets the base number of channels.

Methods

Method Summary
IReadOnlyList<ILayer<T>> GetSubLayers()
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank)
void ResetState()
void UpdateParameters(T learningRate)