mirror of
https://github.com/wassname/ray.git
synced 2026-07-21 12:50:45 +08:00
[RLlib] Fix test_bc.py test case. (#11722)
* Fix large json test file. * Fix large json test file. * WIP.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user