Created
November 8, 2016 07:22
-
-
Save taotao54321/cec152162be9888c0e55c9d588460fe0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
import json | |
import numpy as np | |
def error(msg): | |
sys.exit(msg) | |
def running_mean(x, n): | |
cumsum = np.cumsum(np.insert(x, 0, 0)) | |
return (cumsum[n:] - cumsum[:-n]) / n | |
def usage(): | |
error("Usage: judge <overall_count> <trial_count> <json>") | |
def main(): | |
if len(sys.argv) != 4: usage() | |
overall_count = int(sys.argv[1]) | |
trial_count = int(sys.argv[2]) | |
stats_path = sys.argv[3] | |
with open(stats_path, "r") as in_: | |
stats = json.load(in_) | |
rewards = stats["episode_rewards"] | |
avg_overall = np.mean(rewards[-overall_count:]) | |
avg_best = max(running_mean(rewards, trial_count)) | |
print("overall: {}".format(avg_overall)) | |
print("best: {}".format(avg_best)) | |
if __name__ == "__main__": main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment