TorchLean API

NN.API.Models.Generative

Generative Model Helpers (API) #

Small config-style constructors for runnable generative examples.

These are intentionally vector models: examples can flatten images, train the model, and later swap in convolutional encoders/decoders without changing the command-line/data-loading surface.

Shared dimensions for vector generative examples.

Instances For
    def NN.API.nn.models.vectorGenerativeConfig (batch dataDim hiddenDim latentDim : ) :

    Convenience constructor for compact vector generative models.

    Instances For
      def NN.API.nn.models.compactImageConfig (batch : := 4) (dataDim : := 128) (hiddenDim : := 64) (latentDim : := 32) :

      Small default config used by the runnable image-vector examples.

      The input dimension is intentionally a prefix of a flattened image, not a full image decoder. That keeps examples fast while still exercising real data, batched training, and generative model constructors.

      Instances For
        @[reducible, inline]
        Instances For
          @[reducible, inline]
          Instances For
            @[reducible, inline]

            β-VAE-style supervised output shape.

            Rows contain:

            The runnable example trains this compact target with MSE, which is a practical path for the runtime. The formal VAE ELBO/KL objective lives in NN.Spec.Models.Vae and NN.MLTheory.Generative.Latent.VAE.

            Instances For

              Flatten each sample in a batch and keep the first cfg.dataDim entries.

              This is useful for quick image-vector experiments: a model can train on a small typed vector view of an image without every example needing to carry its own flattening proof adapters.

              Instances For

                Supervised reconstruction sample: target equals input.

                Instances For

                  Target for compact VAE-style examples.

                  Rows contain the reconstruction target followed by zero mean/log-variance proxy channels.

                  Instances For

                    Supervised compact VAE sample: image reconstruction plus zero latent-stat targets.

                    Instances For
                      def NN.API.nn.models.vectorNoise (batch dim seed salt : ) (lo hi : Float) :

                      Deterministic matrix-valued pseudo-random tensor in [lo, hi).

                      Instances For

                        Deterministic latent noise for generator examples.

                        Instances For

                          Deterministic data-shaped noise for discriminator examples.

                          Instances For

                            Constant discriminator/critic target.

                            Instances For

                              Target score for real samples.

                              Instances For

                                Target score for generated or noise samples.

                                Instances For

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

                                  Instances For

                                    Compact β-VAE-style network producing reconstruction plus latent statistics.

                                    Instances For

                                      VQ-VAE-style encoder/decoder with a narrow discrete-code proxy bottleneck.

                                      Instances For

                                        Discriminator/critic x -> score.

                                        Instances For