I don’t really understand actor-critic training, but it seems that such models
are hotbeds for inplace-modification errors. You might start by looking at this discussion of some of the ways such errors can arise
Do you call .backward (retain_graph = True) anywhere? Doing so is
sometimes (usually?) incorrect and can lead to inplace-modification errors.
Note that the shape of the problem tensor, [512, 25], can be a useful
piece of information, see below.
Based on the forward-call traceback and the shape reported for the problem
tensor, it looks like last_fc of one of your Critics – a tensor presumably
being optimized – is the cause of your problem.
One possibility is that you are doing something like:
loss.backward (retain_graph = True) # leaves Critic.last_fc in what will become a stale computation graph
...
opt.step() # counts as an inplace modification
...
loss.backward (...) # backpropagates through the stale graph and hits the modified Critic.last_fc
In any event, you can find various methods for finding inplace-modification errors in the following post (which happens to be about an actor-critic model):