TorchLean API

NN.API.Data.Transforms

Dataset and Sample Transforms (Torchvision-Style) #

This module provides a small transform library inspired by torchvision.transforms:

PyTorch Mapping #

TorchLean difference: transforms are pure functions over typed tensors/samples, so shape mistakes are caught by the typechecker rather than at runtime.

def NN.API.Data.Transforms.Compose {a : Type} (ts : List (aa)) :
aa

Torchvision-style transform composition.

Applies transforms left-to-right:

Compose [f, g, h] x = h (g (f x)).

Instances For
    def NN.API.Data.Transforms.Lambda {a : Type} (f : aa) :
    aa

    Torchvision-style "Lambda" transform wrapper.

    Instances For
      def NN.API.Data.Transforms.compose {a b c : Type} (g : bc) (f : ab) :
      ac

      Compose two pure transforms.

      Instances For
        def NN.API.Data.Transforms.onDataset {a b : Type} (f : ab) (ds : Dataset a) :

        Apply a pure transform to every element of a dataset.

        Instances For
          def NN.API.Data.Transforms.mapTensor {α : Type} {s : Spec.Shape} (f : αα) (x : Spec.Tensor α s) :

          Map a tensor elementwise.

          Instances For
            def NN.API.Data.Transforms.normalizeTensor {α : Type} [Sub α] [Div α] {s : Spec.Shape} (mean std : α) (x : Spec.Tensor α s) :

            Normalize any tensor elementwise: (x - mean) / std.

            Instances For
              def NN.API.Data.Transforms.normalizeTensorF {α : Type} [Runtime.Scalar α] [Sub α] [Div α] {s : Spec.Shape} (mean std : Float) (x : Spec.Tensor α s) :

              Float-literal normalization helper for runtime scalar backends.

              Instances For
                def NN.API.Data.Transforms.mapLabels {a : Type} (f : ) (xs : List (a × )) :
                List (a × )

                Transform labels in (sample, label) datasets.

                Instances For
                  def NN.API.Data.Transforms.mapSamples {a b : Type} (f : ab) (xs : List (a × )) :
                  List (b × )

                  Transform samples in (sample, label) datasets.

                  Instances For
                    def NN.API.Data.Transforms.onSamples {a b : Type} (f : ab) (ds : Dataset (a × )) :

                    Apply a sample transform to a labeled dataset.

                    Instances For
                      def NN.API.Data.Transforms.onLabels {a : Type} (f : ) (ds : Dataset (a × )) :

                      Apply a label transform to a labeled dataset.

                      Instances For

                        Transform the input component of a supervised TorchLean sample TList α [σ, τ].

                        Instances For

                          Transform the target component of a supervised TorchLean sample TList α [σ, τ].

                          Instances For

                            Apply an input transform over a supervised TorchLean dataset.

                            Instances For