TorchLean API

NN.GraphSpec.Models.Classifier

GraphSpec Classifier Head #

A classifier takes a typed feature chain, flattens its output, and applies a linear head. The feature chain determines its own depth, channel widths, spatial geometry, and parameter shapes. Its stages can use different convolution and pooling configurations.

def NN.GraphSpec.Models.classifier {parameters : List Spec.Shape} {input featureShape : Spec.Shape} (features : Chain parameters input featureShape) (outputSize : ℕ) :
Chain (parameters ++ [[outputSize, featureShape.size], [outputSize]]) input [outputSize]

Attach a linear classifier to an arbitrary feature chain.

Parameters remain in feature-chain order, followed by the head's weight and bias. An identity feature chain gives a linear classifier on the flattened input. The general chain-to-DAG conversion applies to the resulting classifier without a model-specific wrapper.

Instances For
    theorem NN.GraphSpec.Models.classifier_interp {α : Type} [TorchLean.Storage α] [Context α] {parameters : List Spec.Shape} {input featureShape : Spec.Shape} {outputSize : ℕ} (features : Chain parameters input featureShape) (state : TorchLean.TensorPack α parameters) (head : Spec.LinearSpec α featureShape.size outputSize) (x : TorchLean.Tensor α input) :

    The classifier applies its head to the flattened feature output, preserving parameter order.