https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LibtorchRLPPOLoss.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#ifdef MOOSE_LIBTORCH_ENABLED
11
12#pragma once
13
17
22{
24 torch::Tensor actor_loss;
26 torch::Tensor critic_loss;
28 torch::Tensor entropy;
29};
30
35{
36public:
42 LibtorchRLPPOLoss(Real clip_parameter, Real entropy_coeff);
43
52 const LibtorchRLMiniBatch & batch) const;
53
54private:
59 static torch::Tensor reduceActionDimension(const torch::Tensor & tensor);
60
62 const Real _clip_parameter;
64 const Real _entropy_coeff;
65};
66
67#endif
PPO clipped surrogate loss on top of the reusable RL buffer/value-estimation core.
static torch::Tensor reduceActionDimension(const torch::Tensor &tensor)
Collapse multi-action log-probabilities or entropies into one column tensor.
const Real _entropy_coeff
Weight applied to the entropy bonus inside the actor loss.
const Real _clip_parameter
PPO clipping width used in the actor surrogate objective.
LibtorchRLPPOLossOutput compute(Moose::LibtorchActorNeuralNet &policy_network, Moose::LibtorchArtificialNeuralNet &value_network, const LibtorchRLMiniBatch &batch) const
Compute actor, critic, and entropy terms for one mini-batch.
Feed-forward actor network coupled to a Gaussian or Beta action distribution.
Tensor data for one PPO mini-batch.
Actor, critic, and entropy terms produced by one PPO loss evaluation.
torch::Tensor actor_loss
Clipped actor loss for the current mini-batch.
torch::Tensor critic_loss
Critic regression loss for the current mini-batch.
torch::Tensor entropy
Mean action-distribution entropy for the current mini-batch.