TorchLean API

NN.API.Trainer.Predict

Prediction and Training #

Prediction and training methods on Trainer.Handle.

Predict one Float input through a runtime runner and return a Float output.

Instances For

    Predict one input through a custom-loss trainer without first running training.

    Instances For

      Build the regression dispatch record used by Handle.train.

      Instances For

        Build the cross-entropy dispatch record used by Handle.train.

        Instances For
          def TorchLean.Trainer.Implementation.customHandle {σ τ : Shape} (trainer : Handle σ τ) (loss : {α : Type} → [inst : Context α] → [inst_1 : DecidableEq Shape] → Runtime.Autograd.TorchLean.Program α [τ, τ] Shape.scalar) :
          Custom σ τ

          Build the custom-loss dispatch record used by Handle.train.

          Instances For
            def TorchLean.Trainer.Handle.predict {σ τ : Shape} (trainer : Handle σ τ) (x : Tensor.T Float σ) :

            Predict one input using the trainer's current model and runtime settings.

            Inference before any training call. After training, use the returned trained handle's trained.predict / trained.predictBatch methods to predict with the trained parameters.

            Instances For
              def TorchLean.Trainer.Handle.predictBatch {σ τ : Shape} (trainer : Handle σ τ) (xs : List (Tensor.T Float σ)) :

              Predict a list of inputs using the trainer's current model and runtime settings.

              Instances For
                def TorchLean.Trainer.Handle.train {σ τ : Shape} (trainer : Handle σ τ) (data : Dataset σ τ) (trainOptions : TrainOptions := { }) (probes : List (Probe σ) := []) :
                IO (TrainResult σ τ)

                Train the model with the loss and runtime settings stored in trainer.

                The result stores the trained parameters together with prediction and reporting methods.

                Instances For
                  def TorchLean.Trainer.Handle.trainStreamFloat {σ τ : Shape} (trainer : Handle σ τ) (opts : Options) (sampleAt : SupervisedSample Float σ τ) (evalSample : SupervisedSample Float σ τ) (trainOptions : TrainOptions := { }) (curveEvery cudaMemWatch : := 0) (onEval : String(Tensor.T Float σIO (Tensor.T Float τ))IO Unit := fun (x : ) (x_1 : String) (x_2 : Tensor.T Float σIO (Tensor.T Float τ)) => pure ()) :

                  Train a regression model from a Float sample stream.

                  Generated-data examples use this when there is no fixed Dataset to hand to trainer.train.

                  Instances For
                    def TorchLean.Trainer.Handle.trainPairStreamFloat {σ₁ τ₁ σ₂ τ₂ : Shape} (first : Handle σ₁ τ₁) (second : Handle σ₂ τ₂) (opts : Options) (firstSampleAt : SupervisedSample Float σ₁ τ₁) (secondSamplesAt : List (SupervisedSample Float σ₂ τ₂)) (evalTotal : (Tensor.T Float σ₁IO (Tensor.T Float τ₁))(Tensor.T Float σ₂IO (Tensor.T Float τ₂))IO Float) (trainOptions : TrainOptions := { }) (curveEvery : := 1) (cudaMemWatch : := 0) :
                    IO (PairStreamTrainResult σ₁ τ₁ σ₂ τ₂)

                    Train two regression models from coupled Float streams.

                    GAN-style examples use this path when two regression trainers have to step together, without opening the lower-level runtime modules directly.

                    Instances For
                      def TorchLean.Trainer.Handle.trainSelectedCrossEntropy {σ τ : Shape} {α : Type} [Context α] [DecidableEq Shape] [ToString α] [Runtime.FromFloat α] (trainer : Handle σ τ) (opts : Options) (data : Dataset σ τ) (trainOptions : TrainOptions := { }) (probes : List (Probe σ) := []) :
                      IO (TrainResult σ τ)

                      Train a cross-entropy model after the scalar type has already been selected.

                      Use this path from a runtime callback where Lean has already selected a concrete scalar α.

                      Instances For