RLDataLoaderBase<T>
Base Classes ยท AiDotNet.Data.Loaders
Abstract base class for RL data loaders providing common reinforcement learning functionality.
Inheritance: DataLoaderBase<T> โ RLDataLoaderBase<T>
Implements: IRLDataLoader<T>
Known derived types: EnvironmentDataLoader<T>
For Beginners
This base class handles common RL operations:
- Stepping through the environment collecting experiences
- Storing experiences in a replay buffer
- Sampling batches for training
Concrete implementations extend this to work with specific environments or provide specialized experience collection strategies.
How It Works
RLDataLoaderBase provides shared implementation for all RL data loaders including:
- Environment interaction management
- Replay buffer management
- Episode running and experience collection
- Batch sampling for training
Properties
| Property | Summary |
|---|---|
IEnvironment<T> Environment { get; } |
|
IReplayBuffer<T, Vector<T>, Vector<T>> ReplayBuffer { get; } |
|
bool HasNext { get; } |
|
bool Verbose { get; } |
|
int BatchSize { get; set; } |
|
int CurrentEpisode { get; } |
|
int Episodes { get; } |
|
int MaxStepsPerEpisode { get; } |
|
int MinExperiencesBeforeTraining { get; } |
|
int TotalCount { get; } |
|
int TotalSteps { get; } |
Methods
| Method | Summary |
|---|---|
EpisodeResult<T> RunEpisode(IRLAgent<T> agent) |
|
Experience<T, Vector<T>, Vector<T>> GetNextBatch() |
|
IAsyncEnumerable<Experience<T, Vector<T>, Vector<T>>> GetBatchesAsync(int? batchSize, bool shuffle, bool dropLast, int? seed, int prefetchCount, CancellationToken cancellationToken) |
|
IEnumerable<Experience<T, Vector<T>, Vector<T>>> GetBatches(int? batchSize, bool shuffle, bool dropLast, int? seed) |
|
IReadOnlyList<EpisodeResult<T>> RunEpisodes(int numEpisodes, IRLAgent<T> agent) |
|
IReadOnlyList<Experience<T, Vector<T>, Vector<T>>> SampleBatch(int batchSize) |
|
bool CanTrain(int batchSize) |
|
bool TryGetNextBatch(Experience<T, Vector<T>, Vector<T>> batch) |
|
void AddExperience(Experience<T, Vector<T>, Vector<T>> experience) |
|
void ResetTraining() |
|
void SetSeed(int seed) |