Rename predict to forward
This is done to be consistent with stable baselines interface. predict is then automatically defined. This is necessary to use stable baselines' evaluate_policy method
This commit is contained in:
@@ -36,7 +36,7 @@ class OptionsEnv(gym.Wrapper):
|
|||||||
self.episode_start = True
|
self.episode_start = True
|
||||||
|
|
||||||
self.m = available_actions(self.env, self.options)
|
self.m = available_actions(self.env, self.options)
|
||||||
self.ch, self.value, self.log_prob = generator.policy.predict({
|
self.ch, self.value, self.log_prob = generator.policy.forward({
|
||||||
'obs': torch.tensor(self.s).unsqueeze(0).to(generator.policy.device),
|
'obs': torch.tensor(self.s).unsqueeze(0).to(generator.policy.device),
|
||||||
'mask': torch.tensor(self.m).unsqueeze(0).to(generator.policy.device),
|
'mask': torch.tensor(self.m).unsqueeze(0).to(generator.policy.device),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class OptionsCnnPolicy(stable_baselines3.common.policies.ActorCriticCnnPolicy):
|
|||||||
values = self.value_net(latent_vf)
|
values = self.value_net(latent_vf)
|
||||||
return values, distribution.distribution
|
return values, distribution.distribution
|
||||||
|
|
||||||
def predict(self, obs, eps=1e-6):
|
def forward(self, obs, eps=1e-6):
|
||||||
"""
|
"""
|
||||||
Will mask invalid states before making action selections
|
Will mask invalid states before making action selections
|
||||||
Args:
|
Args:
|
||||||
|
|||||||
Reference in New Issue
Block a user