This error happen when I try to : get output from the layer  before last layer as features, and try to compute loss with an expected features, then propagate and update the input (not the network’s weight, but the input)  using cosine similarity loss. I cannot find any clue about this bug. Is there anyone meet this problem before?