Table of Contents

Class PostprocessorBase<T, TInput, TOutput>

Namespace
AiDotNet.Postprocessing
Assembly
AiDotNet.dll

Abstract base class for all postprocessors providing common functionality.

public abstract class PostprocessorBase<T, TInput, TOutput> : IPostprocessor<T, TInput, TOutput>

Type Parameters

T

The numeric type for calculations (e.g., float, double).

TInput

The input data type (model output).

TOutput

The output data type after postprocessing.

Inheritance
PostprocessorBase<T, TInput, TOutput>
Implements
IPostprocessor<T, TInput, TOutput>
Derived
Inherited Members

Remarks

This class provides the template method pattern for postprocessing. Derived classes implement the core processing logic while this base class handles validation, configuration, and common operations.

For Beginners: This is the foundation that all postprocessors build on. It provides common features like: - Configuration management - Batch processing support - Error handling

When creating a new postprocessor, you extend this class and implement the abstract methods.

Constructors

PostprocessorBase()

Creates a new instance of the postprocessor.

protected PostprocessorBase()

Properties

IsConfigured

Gets whether this postprocessor is configured and ready to use.

public bool IsConfigured { get; protected set; }

Property Value

bool

NumOps

Gets the numeric operations helper for type T.

protected INumericOperations<T> NumOps { get; }

Property Value

INumericOperations<T>

Settings

Gets the configuration settings for this postprocessor.

protected Dictionary<string, object> Settings { get; }

Property Value

Dictionary<string, object>

SupportsInverse

Gets whether this postprocessor supports inverse transformation.

public abstract bool SupportsInverse { get; }

Property Value

bool

Methods

Configure(Dictionary<string, object>?)

Configures the postprocessor with optional settings.

public virtual void Configure(Dictionary<string, object>? settings = null)

Parameters

settings Dictionary<string, object>

Optional configuration dictionary.

ConfigureCore(Dictionary<string, object>?)

Core configuration implementation. Override to handle specific settings.

protected virtual void ConfigureCore(Dictionary<string, object>? settings)

Parameters

settings Dictionary<string, object>

The configuration settings.

EnsureConfigured()

Ensures the postprocessor is configured before use.

protected void EnsureConfigured()

Exceptions

InvalidOperationException

Thrown if not configured.

GetSetting<TSetting>(string, TSetting)

Gets a setting value with type conversion.

protected TSetting GetSetting<TSetting>(string key, TSetting defaultValue)

Parameters

key string

The setting key.

defaultValue TSetting

Default value if not found.

Returns

TSetting

The setting value or default.

Type Parameters

TSetting

The expected setting type.

Inverse(TOutput)

Reverses the postprocessing (if supported).

public TInput Inverse(TOutput output)

Parameters

output TOutput

The postprocessed result.

Returns

TInput

The original model output format.

Exceptions

NotSupportedException

Thrown if inverse is not supported.

InverseCore(TOutput)

Core inverse transformation implementation. Override this in derived classes.

protected virtual TInput InverseCore(TOutput output)

Parameters

output TOutput

The output to invert.

Returns

TInput

The inverted input.

Process(TInput)

Transforms model output into the final result format.

public TOutput Process(TInput input)

Parameters

input TInput

The model output to process.

Returns

TOutput

The postprocessed result.

Exceptions

InvalidOperationException

Thrown if not configured.

ProcessBatch(IEnumerable<TInput>)

Transforms a batch of model outputs.

public virtual IList<TOutput> ProcessBatch(IEnumerable<TInput> inputs)

Parameters

inputs IEnumerable<TInput>

The model outputs to process.

Returns

IList<TOutput>

The postprocessed results.

ProcessCore(TInput)

Core processing implementation. Override this in derived classes.

protected abstract TOutput ProcessCore(TInput input)

Parameters

input TInput

The input to process.

Returns

TOutput

The processed output.

ValidateInput(TInput)

Validates input before processing.

protected virtual void ValidateInput(TInput input)

Parameters

input TInput

The input to validate.

Exceptions

ArgumentNullException

Thrown if input is null.