def test_selfplay_console_writer(self): with self.assertLogs("mlagents.trainers", level="INFO") as cm: category = "category1" console_writer = ConsoleWriter() console_writer.add_property(category, StatsPropertyType.SELF_PLAY, True) console_writer.add_property(category, StatsPropertyType.SELF_PLAY_TEAM, 1) statssummary1 = StatsSummary(mean=1.0, std=1.0, num=1) console_writer.write_stats( category, { "Environment/Cumulative Reward": statssummary1, "Is Training": statssummary1, "Self-play/ELO": statssummary1, "Self-play/Mean Opponent ELO": statssummary1, "Self-play/Std Opponent ELO": statssummary1, }, 10, ) self.assertIn("Mean Reward: 1.000. Std of Reward: 1.000. Training.", cm.output[0]) self.assertIn( "category1 Team 1: ELO: 1.000. Mean Opponent ELO: 1.000. Std Opponent ELO: 1.000.", cm.output[1], )
def test_console_writer(self): # Test write_stats with self.assertLogs("mlagents.trainers", level="INFO") as cm: category = "category1" console_writer = ConsoleWriter() statssummary1 = StatsSummary(mean=1.0, std=1.0, num=1) console_writer.write_stats( category, { "Environment/Cumulative Reward": statssummary1, "Is Training": statssummary1, }, 10, ) statssummary2 = StatsSummary(mean=0.0, std=0.0, num=1) console_writer.write_stats( category, { "Environment/Cumulative Reward": statssummary1, "Is Training": statssummary2, }, 10, ) # Test hyperparameter writing console_writer.add_property( "category1", StatsPropertyType.HYPERPARAMETERS, {"example": 1.0} ) self.assertIn( "Mean Reward: 1.000. Std of Reward: 1.000. Training.", cm.output[0] ) self.assertIn("Not Training.", cm.output[1]) self.assertIn("Hyperparameters for behavior name", cm.output[2]) self.assertIn("example:\t1.0", cm.output[2])
def test_selfplay_console_writer(self): with self.assertLogs("mlagents.trainers", level="INFO") as cm: category = "category1" console_writer = ConsoleWriter() console_writer.add_property(category, StatsPropertyType.SELF_PLAY, True) statssummary1 = StatsSummary( mean=1.0, std=1.0, num=1, sum=1.0, aggregation_method=StatsAggregationMethod.AVERAGE, ) console_writer.write_stats( category, { "Environment/Cumulative Reward": statssummary1, "Is Training": statssummary1, "Self-play/ELO": statssummary1, }, 10, ) self.assertIn("Mean Reward: 1.000. Std of Reward: 1.000. Training.", cm.output[0])