使用pytorch和python实现自动驾驶汽车时,出现此错误。
File "C:\Users\Ganesh Bhat\Desktop\AI\Self_Driving_Car\ai.py", line 86, in update
self.memory.push((self.last_state,new_state,torch.LongTensor([int(self.last_action)])),torch.tensor([self.last_reward]))
TypeError: 'module' object is not callable
here is my code of update function
def update(self,reward, new_signal):
new_state = torch.Tensor(new_signal).float().unsqueeze(0)
self.memory.push((self.last_state,new_state,torch.LongTensor([int(self.last_action)]),torch.tensor([self.last_reward])))
action = self.select_action(new_state)
if len(self.memory.memory) > 100:
batch_state, batch_next_state, batch_reward, batch_action = self.memory.sample(100)
self.learn(batch_state, batch_next_state, batch_reward, batch_action)
self.last_action = action
self.last_state = new_state
self.last_reward = reward
self.reward_window.append(reward)
if len(self.reward_window)>1000:
del self.reward_window[0]
return action