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 the data and hidden widths used by every dense generative model.

    Instances For

      Validate all 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. Only the data and hidden widths are used; the latent width does not affect this model.

                    Instances For