For Alexnet just do:
from torch.legacy import nn
n.modules[13] = nn.View(1,9216)
(instead of nn.View(9216))
For enet it’s trickier. There are several errors in the pytorch legacy code.
First of all the error you get (‘SpatialMaxPooling’ object has no attribute ‘indices’) is because there is an error in SpatialMaxPooling.py 10 inside pytorch. In line 34, instead of
if self.indices is None:, it should be
if not hasattr(self, ‘indices’):
This probably comes from a wrong Lua->Python conversion of the code.
Then in JoinTable.py 6 line
dimension = self.dimension should become dimension = self.dimension-1
Then in Padding.py 3 nInputDim is totally missing. You can temporarily fix this by changing self.dim in lines 19 and 21 of Padding.py 3 into self.dim+1.
Then you have again the View issue at the end.
After all these changes, it will run.