TorchLean API

NN.Spec.Module.GlobalPooling

Global pooling as NNModuleSpecs #

Global pooling is a common "bridge" from convolutional feature maps to a classifier head: it reduces the spatial dimensions and keeps only the channel axis.

This file wraps the flat global pooling specs from NN/Spec/Layers/GlobalPooling.lean as NNModuleSpecs so they can be composed with SpecChain (and recognized by export tooling).

We focus on the flat variants because most model definitions here use them directly:

def Spec.GlobalAvgPool2DFlatModuleSpec {α : Type} [Context α] {inC inH inW : } (hH : inH 0) (hW : inW 0) (layer : GlobalAvgPool2DSpec := { }) :

Global average pooling (flattened): (C,H,W) -> (C).

Instances For
    def Spec.GlobalMaxPool2DFlatModuleSpec {α : Type} [Context α] {inC inH inW : } (hH : inH 0) (hW : inW 0) (layer : GlobalMaxPool2DSpec := { }) :

    Global max pooling (flattened): (C,H,W) -> (C).

    Instances For