Module record

Source
Expand description

Types and traits for recording and managing training metrics.

This module provides a comprehensive system for recording, storing, and managing various types of data during reinforcement learning training and evaluation. It includes support for different data types, aggregation, and flexible storage backends.

§Core Components

  • Record - A flexible container for storing key-value pairs of various data types
  • RecordValue - An enum representing different types of values that can be stored
  • Recorder - A trait defining the interface for recording and storing data
  • RecordStorage - A storage system with aggregation capabilities
  • BufferedRecorder - A recorder that temporarily stores records in memory
  • NullRecorder - A recorder that discards all records (useful for testing)

§Basic Usage

use border_core::record::{Record, RecordValue};

// following values are obtained with some process in reality
let step = 1;
let obs = vec![1f32, 2.0, 3.0, 4.0, 5.0];
let reward = -1f32;

let mut record = Record::empty();
record.insert("Step", RecordValue::Scalar(step as f32));
record.insert("Reward", RecordValue::Scalar(reward));
record.insert("Obs", RecordValue::Array1(obs));

§Integration with Training

The recording system is designed to work seamlessly with the training process. The Trainer uses a Recorder to log training metrics and other relevant information during the training loop.

§Data Types

The module supports various data types through RecordValue:

  • Scalar(f32) - Single floating-point values
  • DateTime(DateTime<Local>) - Timestamps
  • Array1(Vec<f32>) - 1-dimensional arrays
  • Array2(Vec<f32>, [usize; 2]) - 2-dimensional arrays with shape
  • Array3(Vec<f32>, [usize; 3]) - 3-dimensional arrays with shape
  • String(String) - Text values

Structs§

BufferedRecorder
A recorder that buffers sequences of observations and actions in memory.
NullRecorder
A recorder that discards all records without storing them.
Record
A container for storing key-value pairs of various data types.
RecordStorage
A storage system for records with aggregation capabilities.

Enums§

RecordValue
Represents possible types of values that can be stored in a Record.

Traits§

Recorder
A trait for recording training metrics and managing model persistence.