I think I found it. I used following for reference:
Though, instead of
learn.model[-1][-1]=nn.Linear(in_features=512,out_features=5, bias=True)
I did learn.model[-2] = nn.Linear(in_features=512,out_features=5, bias=True), as for me the last layer was softmax