~enan/ros-rl

2592579618beaa824e8d558292c0120a6768fa08 — Enan Ajmain 2 years ago d69b794
td3: save only actor model for deploying

Critic models aren't used when testing the agent. BUT if/when we have to
train it over multiple days or in multiple environments and have to
break the session up, we will have to save critic models too.
1 files changed, 0 insertions(+), 4 deletions(-)

M src/td3.py
M src/td3.py => src/td3.py +0 -4
@@ 368,14 368,10 @@ class TD3Agent():
    def save(self, directory, filename):
        print("Saving model . . .")
        torch.save(self.actor.state_dict(), '%s/%s_actor.pth' % (directory, filename))
        torch.save(self.critic1.state_dict(), '%s/%s_critic1.pth' % (directory, filename))
        torch.save(self.critic2.state_dict(), '%s/%s_critic2.pth' % (directory, filename))

    def load(self, directory, filename):
        print("Loading model . . .")
        self.actor.load_state_dict(torch.load('%s/%s_actor.pth' % (directory, filename)))
        self.critic1.load_state_dict(torch.load('%s/%s_critic1.pth' % (directory, filename)))
        self.critic2.load_state_dict(torch.load('%s/%s_critic2.pth' % (directory, filename)))

"""## Environment
*ActionNormalizer* is an action wrapper class to normalize the action values