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

CEM #373

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

CEM #373

wants to merge 18 commits into from

Conversation

hades-rp2010
Copy link
Member

Wrt #363

@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #373 into master will decrease coverage by 0.03%.
The diff coverage is 90.09%.

@@            Coverage Diff             @@
##           master     #373      +/-   ##
==========================================
- Coverage   91.28%   91.25%   -0.04%     
==========================================
  Files          90       92       +2     
  Lines        3809     3910     +101     
==========================================
+ Hits         3477     3568      +91     
- Misses        332      342      +10     
Impacted Files Coverage Δ
genrl/agents/modelbased/base.py 71.42% <71.42%> (ø)
genrl/agents/modelbased/cem/cem.py 94.87% <94.87%> (ø)
genrl/agents/__init__.py 100.00% <100.00%> (ø)

@lgtm-com
Copy link

lgtm-com bot commented Oct 5, 2020

This pull request introduces 3 alerts when merging a90e8d0 into 52b0b4c - view on LGTM.com

new alerts:

  • 3 for Unused import

@sampreet-arthi sampreet-arthi added this to In progress in Model Based RL Oct 12, 2020
@lgtm-com
Copy link

lgtm-com bot commented Oct 15, 2020

This pull request introduces 4 alerts when merging 3b2067d into 25eb018 - view on LGTM.com

new alerts:

  • 4 for Unused import

@hades-rp2010 hades-rp2010 changed the title [WIP] CEM CEM Oct 15, 2020
Copy link
Member

@sampreet-arthi sampreet-arthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Mostly just doubts. How's the performance of the agent now? (Does it hit 500?)

raise NotImplementedError


class ModelBasedAgent(ABC):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this inherit from the genrl/deep BaseAgent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can, and I think thats a better option (for now at least)

# No need for this here
pass

def collect_rollouts(self, state: torch.Tensor):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty similar to the OnPolicyAgent method. Shouldn't this return values and dones though? Not sure if this is a consequence of the algo.

for i, done in enumerate(dones):
if done or timestep == self.rollout_size - 1:
self.rewards.append(self.env.episode_reward[i].detach().clone())
# self.env.reset_single_env(i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out? This is necessary to reset environments immediately as they are set to done. (Not a good practice to do env.step() if the env is already returning done = True)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I am breaking the loop of actions if a env.step() returns done=True, and every plan session (the plan function) starts with env.reset(), I think this is redundant here, hence its commented out

tests/test_deep/test_agents/test_cem.py Outdated Show resolved Hide resolved


def test_CEM():
env = VectorEnv("CartPole-v0", 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set it to 1? It does work with multiple envs right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it does

@sampreet-arthi
Copy link
Member

Also, forgot to mention the docs. The CEM agent code didn't have docstrings afair.

@sampreet-arthi sampreet-arthi linked an issue Oct 16, 2020 that may be closed by this pull request
from genrl.trainers import OnPolicyTrainer


def test_CEM():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please make this a class so the tests are easier to find/understand

@hades-rp2010
Copy link
Member Author

Also, forgot to mention the docs. The CEM agent code didn't have docstrings afair.

Yeah, I'll get that done too

@lgtm-com
Copy link

lgtm-com bot commented Oct 17, 2020

This pull request introduces 2 alerts when merging f5a189d into 25eb018 - view on LGTM.com

new alerts:

  • 2 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Oct 21, 2020

This pull request introduces 2 alerts when merging 4b11c16 into 25eb018 - view on LGTM.com

new alerts:

  • 2 for Unused import

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Model Based RL
  
In progress
Development

Successfully merging this pull request may close these issues.

CEM for Model based agents
2 participants