Convert model to matrices that can be handled by numpy

Hello everyone,

Is there a way to transform the torch model into algebraic matrices that can be operated with numpy or basic Python, without the need to install torch and other libraries in a device (system on module)? The libraries need a lot of space and they cannot be handled. In an afirmative case, could you please give me some hints or link with explanation? Thank you very much.

You could certainly rewrite the model in numpy, but note that you wouldn’t be able to train the model directly, since Autograd isn’t implemented (and you couldn’t use other devices such as the GPU).
Are you running into space limitations on your hard disk?

Thank you @ptrblck The thing is that I did not develop the model and was expecting for a tool to obtain the Python code of matrices and more simple operations I would need to perform and handle without torch. Is there something like this?

I only would like to get new forecasts with this model working on a hardware that incorporates Python, and that due to space limitations I cannot install torch. No need to train again.

Thank you very much.

I’m not aware of any library exporting a PyTorch model to plain Python code, as it would most likely be too slow for the majority of use cases.
I’m not sure how space-limited you are, but maybe you could use the CPU-only PyTorch package or build PyTorch from source and remove all accelerators (CUDA, cudnn, NCCL, MKL, etc.).