TorchLean API

NN.Runtime.RL.Algorithms.ValueLearning

Deep Value-Learning Objectives #

This module packages the core scalar objectives / targets behind common deep RL algorithms:

Compute a bootstrap target, then pass it to loss with the selected action. DDPG uses the ordinary Core.discountedBackup for its critic and negates the critic value for its actor. A TD residual is the target minus the selected tensor entry. Replay, target-network synchronization and optimizer orchestration live in higher-level modules.

Primary references:

def Runtime.RL.ValueLearning.maximum {α : Type} [TorchLean.Storage α] [Context α] {nActions : ℕ} (qValues : TorchLean.Tensor α [nActions]) :
α

Maximum Q-value in a vector, defaulting to 0 when nActions = 0.

Instances For
    def Runtime.RL.ValueLearning.dqnTarget {α : Type} [TorchLean.Storage α] [Context α] {nActions : ℕ} (reward gamma : α) (done : Bool) (nextQTarget : TorchLean.Tensor α [nActions]) :
    α

    DQN bootstrap target r + γ max_a Q_target(s', a).

    Instances For
      def Runtime.RL.ValueLearning.doubleDqnTarget {α : Type} [TorchLean.Storage α] [Context α] {nActions : ℕ} (reward gamma : α) (done : Bool) (nextQOnline nextQTarget : TorchLean.Tensor α [nActions]) :
      α

      Double DQN target: select with the online network, evaluate with the target network.

      Instances For
        def Runtime.RL.ValueLearning.loss {α : Type} [TorchLean.Storage α] [Context α] {nActions : ℕ} (q : TorchLean.Tensor α [nActions]) (action : Fin nActions) (target : α) (error : α → α → α := Core.squaredError) :
        α

        Loss for a selected action against a supplied target.

        Compute the target separately with dqnTarget, doubleDqnTarget, or another bootstrap rule. The default is squared error; pass error to use Huber loss or another scalar objective.

        Instances For
          def Runtime.RL.ValueLearning.td3Target {α : Type} [Context α] (reward gamma nextCritic1 nextCritic2 : α) (done : Bool := false) :
          α

          TD3 clipped-double target using the minimum of the two target critics.

          Instances For
            def Runtime.RL.ValueLearning.sacTarget {α : Type} [Context α] (reward gamma nextCritic1 nextCritic2 logProb temperature : α) (done : Bool := false) :
            α

            SAC entropy-regularized soft target: r + γ (min(Q1', Q2') - α * log π(a'|s')).

            Instances For
              def Runtime.RL.ValueLearning.sacActorObjective {α : Type} [Context α] (critic1 critic2 logProb temperature : α) :
              α

              SAC actor objective: minimize α * log π(a|s) - min(Q1, Q2).

              Instances For