Type Error (NoneType)

I’m implementing a deep Q learning algorithm and get the following error when running my code from the command line:

TypeError: mul() received an invalid combination of arguments - got (NoneType), but expected one of:
 * (Tensor other)
      didn't match because some of the arguments have invalid types: (NoneType)
 * (float other)
      didn't match because some of the arguments have invalid types: (NoneType)

The line in question is:
expected_values = next_state_vals * gamma + rewards_t

gamma is a scalar value, and printing next_state_vals.type() and rewards_t.type() show they are both torch.FloatTensor. Printing both tensors confirms this as well.

For some additional context, the preceding lines are as follows with rewards and next_states both as numpy arrays.

rewards_t = torch.FloatTensor(rewards).to(device)
next_states = torch.FloatTensor(next_states).to(device)
next_state_vals = target_network(next_states).max(1)[0]
next_state_vals = next_state_vals.detach()
expected_values = next_state_vals * gamma + rewards_t

Any help would be greatly appreciated!

For some reason my gamma value was getting reset to None and I just never noticed it.

Lesson: don’t code well past your bedtime…