copy over into m.weight.data m.weight.data is of shape: nOutputChannels x nInputChannels x kernelHeight x kernelWidth, so you have to generate nOutputChannels * nInputChannels, then make a numpy array of the same shape as m.weight.data and then copy:

generated_filters = ... # some scipy / numpy logic
m.weight.data.copy_(torch.from_numpy(generated_filters))