Volatile removed no effect

Hi!

I need help. Taking a training course but looks like the code needs to be updated. Since volatile was removed… here is the code and warning:

def select_action(self, state):
    probs = F.softmax(self.model(Variable(state, volatile = True))*100) # T=100
    action = probs.multinomial()
    return action.data[0,0]

/home/ben/Self_Driving_Car/ai.py:63: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
probs = F.softmax(self.model100) # T=100
/home/ben/Self_Driving_Car/ai.py:63: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
probs = F.softmax(self.model
100) # T=100

Any help will be highly appreciated.

Regards,
Ben

Hi,

A new version of this code would be:

@torch.no_grad()
def select_action(self, state):
    probs = F.softmax(self.model(state)*100) # T=100
    action = probs.multinomial()
    return action[0,0]

Thank you very much for your help!

Best regards,

can you help me why here in self.model(…) we have passed argument because it is an instance of network class . And if we can do so how it is associated or utilized inside and instance of a class.