Skip to main content

burn_train/learner/rl/
output.rs

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