TorchLean API

NN.API.Models.Generative

Generative Models #

Config-style constructors for runnable generative examples.

These models act on a trailing feature axis and preserve the caller's batchShape. Examples may flatten structured observations before applying them, while convolutional or operator-based models can use their own shape-specific constructors.

Widths shared by dense generative models.

  • dataWidth :

    Width of the data feature axis.

  • hiddenWidth :

    Width of the hidden layers.

  • latentWidth :

    Width of the latent representation.

Instances For

    Validate shared dense-model widths while naming the public constructor being built.

    Instances For

      Validate every feature width before constructing or seeding a generative model.

      Instances For
        @[reducible, inline]

        Data tensor shape with an arbitrary batch shape.

        Instances For
          @[reducible, inline]

          Latent tensor shape with an arbitrary batch shape.

          Instances For
            @[reducible, inline]

            Scalar-score tensor shape with an arbitrary batch shape.

            Instances For
              def TorchLean.nn.models.Generative.autoencoder (config : Config) (batchShape : Shape := []) :
              Builder (Sequential (config.dataShape batchShape) (config.dataShape batchShape))

              Autoencoder backbone: x -> hidden -> latent -> hidden -> reconstruction.

              The reconstruction is unconstrained. Append an output activation such as nn.sigmoid when the data domain requires one.

              Instances For
                def TorchLean.nn.models.Generative.generator (config : Config) (batchShape : Shape := []) :
                Builder (Sequential (config.latentShape batchShape) (config.dataShape batchShape))

                Generator backbone z -> x.

                The generated values are unconstrained. Choose an output activation at the call site to match the training data and objective.

                Instances For
                  def TorchLean.nn.models.Generative.discriminator (config : Config) (batchShape : Shape := []) :
                  Builder (Sequential (config.dataShape batchShape) (config.scoreShape batchShape))

                  Discriminator x -> logits.

                  Returning logits keeps the model compatible with numerically stable objectives such as TorchLean.Loss.bceWithLogits. Append nn.sigmoid only when probabilities are required.

                  Instances For