Hello,
I am trying to create a neural network that has multiple heads:

image697×459 41.8 KB

I get the error:
param.grad.data.clamp_(-1, 1)
AttributeError: ‘NoneType’ object has no attribute ‘data’
My code looks like this:
if batch_1 and batch_2 and batch_3:
      sum_loss = loss_1 + loss_2 + loss_3
      self.step_optimizer(sum_loss)
      self.update_target_network()

def step_optimizer(self, loss):
     self.optimizer.zero_grad()
     loss.backward()
     for param in self.value_net.parameters():
          param.grad.data.clamp_(-1, 1)
     self.optimizer.step()

I do not understand what I am doing wrong…
Thank you,
Yael