[RLlib] Fix test_bc.py test case. (#11722)

* Fix large json test file.

* Fix large json test file.

* WIP.
This commit is contained in:
Sven Mika
2020-10-31 00:16:09 -07:00
committed by GitHub
parent 48dee789b3
commit bfc4f95e01
3 changed files with 41 additions and 26 deletions
+11 -3
View File
@@ -39,20 +39,28 @@ class TestBC(unittest.TestCase):
config["evaluation_config"] = {"input": "sampler"}
# Learn from offline data.
config["input"] = [data_file]
num_iterations = 300
num_iterations = 350
min_reward = 70.0
# Test for all frameworks.
for _ in framework_iterator(config, frameworks=("tf", "torch")):
trainer = marwil.BCTrainer(config=config, env="CartPole-v0")
learnt = False
for i in range(num_iterations):
eval_results = trainer.train()["evaluation"]
print("iter={} R={}".format(
i, eval_results["episode_reward_mean"]))
# Learn until some reward is reached on an actual live env.
if eval_results["episode_reward_mean"] > 60.0:
# Learn until good reward is reached on an actual live env.
if eval_results["episode_reward_mean"] > min_reward:
print("learnt!")
learnt = True
break
if not learnt:
raise ValueError(
"BCTrainer did not reach {} reward from expert offline "
"data!".format(min_reward))
check_compute_single_action(
trainer, include_prev_action_reward=True)
+10 -2
View File
@@ -43,20 +43,28 @@ class TestMARWIL(unittest.TestCase):
config["evaluation_config"] = {"input": "sampler"}
# Learn from offline data.
config["input"] = [data_file]
num_iterations = 300
num_iterations = 350
min_reward = 70.0
# Test for all frameworks.
for _ in framework_iterator(config):
trainer = marwil.MARWILTrainer(config=config, env="CartPole-v0")
learnt = False
for i in range(num_iterations):
eval_results = trainer.train()["evaluation"]
print("iter={} R={}".format(
i, eval_results["episode_reward_mean"]))
# Learn until some reward is reached on an actual live env.
if eval_results["episode_reward_mean"] > 60.0:
if eval_results["episode_reward_mean"] > min_reward:
print("learnt!")
learnt = True
break
if not learnt:
raise ValueError(
"MARWILTrainer did not reach {} reward from expert "
"offline data!".format(min_reward))
check_compute_single_action(
trainer, include_prev_action_reward=True)
File diff suppressed because one or more lines are too long