I’m trying to perform mutations over the last linear layer of a vgg16 model, and when I put the new weight values to the linear layer, it gives an error: AttributeError: ‘collections.OrderedDict’ object has no attribute ‘eval’ (upon calling model.eval() )
What I’m doing:
# Get weights
weights = model.classifier[6].weight 
# Transform to numpy to perform mutations in cpu (if someone has ideas to do this in GPU I would be grateful)
new_weight = weights.detach().cpu().numpy().flatten()
... mutation ...
# Copying back to model
model.classifier[6].weight.copy_(torch.from_numpy(np.stack(np.split(new_weight, 10))).float())

Doing this, gives the error:
  File "main.py", line 81, in test
    model.eval()
AttributeError: 'collections.OrderedDict' object has no attribute 'eval'

Any suggestions?
Thank you very much