DocumentNeuralNetworkBase<T>

Base Classes · AiDotNet.Document

Base class for document-focused neural networks that can operate in both ONNX inference and native training modes.

Inheritance: NeuralNetworkBase<T> → DocumentNeuralNetworkBase<T>

Implements: IShapeContract

Known derived types: ABINet<T>, Dessurt<T>, DiT<T>, DocBank<T>, DocFormer<T>, DocGCN<T>, DocOwl<T>, Donut<T>, InfographicVQA<T>, LayoutGraph<T>, LayoutLM<T>, LayoutLMv2<T>, LayoutLMv3<T>, LayoutXLM<T>, LiLT<T>, MATCHA<T>, Nougat<T>, PICK<T>, PSENet<T>, Pix2Struct<T>, SVTR<T>, TRIE<T>, TableTransformer<T>, UDOP<T>

For Beginners

Document neural networks process images of documents (scanned pages, PDFs, photos). This base class provides:

  • Support for pre-trained ONNX models (fast inference with existing models)
  • Full training capability from scratch (like other neural networks)
  • Document preprocessing utilities (normalization, resizing, etc.)
  • Layout-aware feature extraction
  • Integration with text encoding for layout-aware models

You can use this class in two ways:

  1. Load a pre-trained ONNX model for quick inference
  2. Build and train a new model from scratch

How It Works

This class extends NeuralNetworkBase to provide document-specific functionality while maintaining full integration with the AiDotNet neural network infrastructure.

Properties

Property Summary
DocumentType SupportedDocumentTypes { get; } Gets the supported document types for this model.
ILossFunction<T> DefaultLossFunction { get; } Gets the default loss function for this model.
bool IsOnnxMode { get; } Gets whether this model is running in ONNX inference mode.
bool RequiresOCR { get; } Gets whether this model requires OCR preprocessing.
bool SupportsTraining { get; } Gets whether this network supports training.
int ImageSize { get; set; } Gets the expected input image size for this model.
int MaxSequenceLength { get; set; } Gets the maximum text sequence length for layout-aware models.

Methods

Method Summary
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) The document family’s law: [Batch, MaxSequenceLength, OutputClassCount].
InputContractManifest GetInputContract(int[] inputShape) Generated public model-boundary contract.
LayerInputDomain GetInputDomain(int[] inputShape) Generated from the primary [TensorPort] declaration.