Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RLlib] Some more bandit cleanup/tests. #21932

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions rllib/agents/bandit/tests/test_bandits.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ def test_bandit_lin_ts_compilation(self):
config = {
# Use a simple bandit friendly env.
"env": SimpleContextualBandit,
# Run locally.
"num_workers": 0,
}

num_iterations = 5
Expand All @@ -38,6 +36,26 @@ def test_bandit_lin_ts_compilation(self):
# Force good learning behavior (this is a very simple env).
self.assertTrue(results["episode_reward_mean"] == 10.0)

def test_bandit_lin_ucb_compilation(self):
"""Test whether a BanditLinUCBTrainer can be built on all frameworks.
"""
config = {
# Use a simple bandit friendly env.
"env": SimpleContextualBandit,
}

num_iterations = 5

for _ in framework_iterator(config, frameworks="torch"):
trainer = bandit.BanditLinUCBTrainer(config=config)
results = None
for i in range(num_iterations):
results = trainer.train()
check_train_results(results)
print(results)
# Force good learning behavior (this is a very simple env).
self.assertTrue(results["episode_reward_mean"] == 10.0)

def test_deprecated_locations(self):
"""Tests, whether importing from old contrib dir fails gracefully.

Expand Down