Converting pytorch model to numpy/ python

Hello,

We are trying to build a custom hardware for binary-matrix-mulitplicaton, we stubled up on xnor-net which uses binary values for the neural network… we were trying to cutomize the implementation used here
GitHub - jiecaoyu/XNOR-Net-PyTorch: PyTorch Implementation of XNOR-Net” , for now we just want to change the matrix multiplication used in nn.Linear to our custom module. But the problem is that the module only works with numpy arrays.
We train the model without using the module , but we want to use our module for prediction with the trained weights. Is there any way to get the trained weights to numpy array and use it to create the model.predict only using numpy.?

Yes, as described in your double post.

Assuming you want to use the numpy arrays only for inference (i.e. no backward calls would be allowed or any gradient calculations) you could write a custom nn.Module and use numpy in the forward method directly.
On the other hand, if you want to calculate gradients, you would need to write a custom autograd.Function and implement the backward method manually.