You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have written a test demo that may help. However, the function def save_or_load_agent(self, cwd: str, if_save: bool) in AgentBase.py has to be modified a little:
def save_or_load_agent(self, cwd: str, if_save: bool):
...
if if_save:
for name, obj in name_obj_list:
save_path = f"{cwd}/{name}.pth"
torch.save(obj.state_dict(), save_path)
else:
for name, obj in name_obj_list:
save_path = f"{cwd}/{name}.pth"
load_torch_file(obj, save_path) if os.path.isfile(save_path) else None return self.act,self.act_target,self.act_optim,self.cri,self.cri_target, self.cri_optim
import torch
from elegantrl.train.utils import init_agent
from elegantrl.train.config import build_env
import gym
from elegantrl.agents.AgentSAC import AgentSAC, AgentModSAC
from elegantrl.envs.Gym import get_gym_env_args
from elegantrl.train.config import Arguments
s=env.reset()
print(s,s.shape)
for i in range(1000):
action=act.get_action(torch.tensor(s))
# agent.train()
next_state,reward,done,_=env.step(action.detach().numpy())
if done:
s=env.reset()
state=next_state
env.render()
Can you provide a test demo, reproduce the optimal policy and save the video? (e.g. for LunarLanderContinuous-v2 or BipedalWalker-v3)
The text was updated successfully, but these errors were encountered: