It seems you are not using Ni in your model architecture, but Fm3 instead.
The number of input features to the first linear layer should match the (flattened) output shape of the preceding layer.
If your conv layer outputs an activation of [batch_size, out_channels, 1, 1], in_features of the linear layer would be equal to out_channels.
However, if the spatial size is larger than 1x1, you would usually flatten the conv output and set in_features=out_channels*h*w.
I haven’t used it personally, but skorch might give you a good interface to sklearn’s grid search etc.