Samples shuffled mini-batches from a flattened on-policy trajectory batch. More...
#include <LibtorchRLMiniBatchSampler.h>
Public Member Functions | |
| std::vector< LibtorchRLMiniBatch > | sample (const LibtorchRLTrajectoryBuffer::TensorBatch &batch, unsigned int batch_size, bool standardize_advantage, c10::optional< at::Generator > generator=c10::nullopt) const |
| Shuffle a flattened rollout batch into PPO-sized chunks. | |
Static Private Member Functions | |
| static void | validateBatch (const LibtorchRLTrajectoryBuffer::TensorBatch &batch) |
| Sanity-check that the flattened rollout tensors all line up. | |
| static LibtorchRLMiniBatch | makeMiniBatch (const LibtorchRLTrajectoryBuffer::TensorBatch &batch, const torch::Tensor &indices, bool standardize_advantage) |
| Slice one shuffled mini-batch out of the flattened rollout tensors. | |
Samples shuffled mini-batches from a flattened on-policy trajectory batch.
Definition at line 46 of file LibtorchRLMiniBatchSampler.h.
|
staticprivate |
Slice one shuffled mini-batch out of the flattened rollout tensors.
| batch | Flattened rollout tensors. |
| indices | Row indices assigned to this mini-batch. |
| standardize_advantage | Whether to normalize the advantages in this slice. |
Definition at line 71 of file LibtorchRLMiniBatchSampler.C.
Referenced by sample().
| std::vector< LibtorchRLMiniBatch > LibtorchRLMiniBatchSampler::sample | ( | const LibtorchRLTrajectoryBuffer::TensorBatch & | batch, |
| unsigned int | batch_size, | ||
| bool | standardize_advantage, | ||
| c10::optional< at::Generator > | generator = c10::nullopt |
||
| ) | const |
Shuffle a flattened rollout batch into PPO-sized chunks.
| batch | Flattened rollout tensors ready for PPO updates. |
| batch_size | Preferred number of rows per mini-batch. |
| standardize_advantage | Whether to normalize the advantages inside each mini-batch. |
| generator | Optional random-number generator used for the row permutation. |
Definition at line 20 of file LibtorchRLMiniBatchSampler.C.
Referenced by LibtorchDRLControlTrainer::trainController().
|
staticprivate |
Sanity-check that the flattened rollout tensors all line up.
| batch | Flattened rollout tensors to validate. |
Definition at line 49 of file LibtorchRLMiniBatchSampler.C.
Referenced by sample().