Torch / Lua, how to save a trained neural network

2019-04-06 00:29发布

问题:

I working on a Torch / Lua project, in which I implemented an artificial neural network model. Everything works, but now I'd like to modify my code in the following way. Since my input dataset are very large, I'd like to divide it in N=20 spans.

Then I want to train my neural network only on the 1st dataset span and then test on the other N-1=19 spans in parallel.

To run all these parallel jobs, I need to save up my neural network model details to a file, and then load it for every 19 jobs.

Is there any way in torch to correctly "write" an artificial neural network model to file?

回答1:

-- save the model
torch.save(filename, model)

.

-- load the model
model = torch.load(filename)