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

Issue SMAC algorithm #146

Closed
ijmarrero opened this issue Sep 24, 2021 · 4 comments
Closed

Issue SMAC algorithm #146

ijmarrero opened this issue Sep 24, 2021 · 4 comments

Comments

@ijmarrero
Copy link

ijmarrero commented Sep 24, 2021

I am having code issues with SMAC implementation (pull request #137)

Traceback (most recent call last):
File "examples/smac/generate_ant_data.py", line 74, in
main()
File "examples/smac/generate_ant_data.py", line 70, in main
use_gpu=gpu,
File "/home/ubuntu/rlkit-master/rlkit/launchers/launcher_util.py", line 605, in run_experiment
**run_experiment_kwargs
File "/home/ubuntu/rlkit-master/rlkit/launchers/launcher_util.py", line 174, in run_experiment_here
return experiment_function(**raw_variant)
File "/home/ubuntu/rlkit-master/rlkit/torch/smac/pearl_launcher.py", line 173, in pearl_experiment
algorithm.train()
File "/home/ubuntu/rlkit-master/rlkit/core/meta_rl_algorithm.py", line 303, in train
self.enc_replay_buffer.task_buffers[task_idx].clear()
AttributeError: 'SimpleReplayBuffer' object has no attribute 'clear'

and

Traceback (most recent call last):
File "examples/smac/generate_ant_data.py", line 74, in
main()
File "examples/smac/generate_ant_data.py", line 70, in main
use_gpu=gpu,
File "/home/ubuntu/rlkit-master/rlkit/launchers/launcher_util.py", line 605, in run_experiment
**run_experiment_kwargs
File "/home/ubuntu/rlkit-master/rlkit/launchers/launcher_util.py", line 174, in run_experiment_here
return experiment_function(**raw_variant)
File "/home/ubuntu/rlkit-master/rlkit/torch/smac/pearl_launcher.py", line 173, in pearl_experiment
algorithm.train()
File "/home/ubuntu/rlkit-master/rlkit/core/meta_rl_algorithm.py", line 436, in train
self.trainer.train(batch)
File "/home/ubuntu/rlkit-master/rlkit/torch/torch_rl_algorithm.py", line 40, in train
self.train_from_torch(batch)
File "/home/ubuntu/rlkit-master/rlkit/torch/smac/pearl.py", line 184, in train_from_torch
action_distrib.rsample_logprob_and_pretanh()
AttributeError: 'TanhNormal' object has no attribute 'rsample_logprob_and_pretanh'

@ijmarrero ijmarrero changed the title Issues with pull request #137 Issue SMAC algorithm Oct 1, 2021
@vitchyr
Copy link
Collaborator

vitchyr commented Oct 3, 2021

@ijmarrero Thanks for bringing up this issue. I must not have caught this when merging this code in. I'll work on testing this further, but it may take me a while. In the meantime:

For the first issue, please add this to rlkit/data_management/simple_replay_buffer.py: SimpleReplayBuffer

    def clear(self):
        self._top = 0
        self._size = 0
        self._episode_starts = []
        self._cur_episode_start = 0

For the second issue, please add this to rlkit.torch.distributions.py:TanhNormal

    def rsample_logprob_and_pretanh(self):
        value, pre_tanh_value = self.rsample_with_pretanh()
        log_p = self.log_prob(value, pre_tanh_value)
        return value, log_p, pre_tanh_value

@ijmarrero
Copy link
Author

Thanks @vitchyr

I have just fixed the code but I new issues arise.

Traceback (most recent call last):
File "examples/smac/generate_ant_data.py", line 74, in
main()
File "examples/smac/generate_ant_data.py", line 70, in main
use_gpu=gpu,
File "/home/ubuntu/rlkit-master/rlkit/launchers/launcher_util.py", line 605, in run_experiment
**run_experiment_kwargs
File "/home/ubuntu/rlkit-master/rlkit/launchers/launcher_util.py", line 174, in run_experiment_here
return experiment_function(**raw_variant)
File "/home/ubuntu/rlkit-master/rlkit/torch/smac/pearl_launcher.py", line 173, in pearl_experiment
algorithm.train()
File "/home/ubuntu/rlkit-master/rlkit/core/meta_rl_algorithm.py", line 436, in train
self.trainer.train(batch)
File "/home/ubuntu/rlkit-master/rlkit/torch/torch_rl_algorithm.py", line 40, in train
self.train_from_torch(batch)
File "/home/ubuntu/rlkit-master/rlkit/torch/smac/pearl.py", line 188, in train_from_torch
policy_log_std = action_distrib.log_std
AttributeError: 'TanhNormal' object has no attribute 'log_std'

@vitchyr
Copy link
Collaborator

vitchyr commented Oct 11, 2021

@ijmarrero this should be fixed with #147 . Let me know if you have any other issues

@vitchyr vitchyr closed this as completed Oct 11, 2021
@ijmarrero
Copy link
Author

ijmarrero commented Oct 13, 2021 via email

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

No branches or pull requests

2 participants