Not sure if I am going in the right direction but here is my fork with a basic attempt to bring SqueezeNet
arch into create_cnn
func:
I have a question about line:
nf = num_features_model(body) * 2
It doesnāt work with SqueezeNet
because during training process an exception is raised:
def batch_norm(input, running_mean, running_var, weight=None, bias=None,
training=False, momentum=0.1, eps=1e-5):
r"""Applies Batch Normalization for each channel across a batch of data.
See :class:`~torch.nn.BatchNorm1d`, :class:`~torch.nn.BatchNorm2d`,
:class:`~torch.nn.BatchNorm3d` for details.
"""
if training:
size = list(input.size())
if reduce(mul, size[2:], size[0]) == 1:
raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(size))
return torch.batch_norm(
input, weight, bias, running_mean, running_var,
> training, momentum, eps, torch.backends.cudnn.enabled
)
E RuntimeError: running_mean should contain 1024 elements not 512
So Iāve introduced an additional meta parameter called mult
to account this issue and multiply 4 instead. Also, squeeze net has a bit different layout and thatās why Iāve created a specific function to detach body:
def _squeezenet_body(m:nn.Module): return m.features
Finally, I am not sure which values to use here:
def _squeezenet_split(m:nn.Module): return (m[1],)
My goal was to make fit_one_cycle
working so I was patching here and there to make it work Could you please tell me if these changes look reasonable? I would like to use this arch in my experiments, so thatās why I am trying to make it work with fastai.
The fork contains a very basic draft and will be arranged into the required format with tests and notebooks if you would like to bring this stuff (when it is ready and approved) into master.