Skip to main content

burn_train/learner/rl/
output.rs

1use crate::{
2    ItemLazy,
3    metric::{Adaptor, CumulativeRewardInput, EpisodeLengthInput},
4};
5use burn_std::ExecutionError;
6
7/// Summary of an episode.
8pub struct EpisodeSummary {
9    /// The total length of the episode.
10    pub episode_length: usize,
11    /// The final cumulative reward.
12    pub cum_reward: f64,
13}
14
15impl ItemLazy for EpisodeSummary {
16    fn sync(self) -> Result<Self, ExecutionError> {
17        Ok(self)
18    }
19}
20
21impl Adaptor<EpisodeLengthInput> for EpisodeSummary {
22    fn adapt(&self) -> EpisodeLengthInput {
23        EpisodeLengthInput::new(self.episode_length as f64)
24    }
25}
26
27impl Adaptor<CumulativeRewardInput> for EpisodeSummary {
28    fn adapt(&self) -> CumulativeRewardInput {
29        CumulativeRewardInput::new(self.cum_reward)
30    }
31}