I am new to Tensorflow and am playing around with some code on github. This code creates a class for the neural network that includes methods to construct the network, formulate the loss function, train the network, perform prediction, etc.
The skeleton code would look something like this:
class NeuralNetwork:
def __init__(...):
def initializeNN():
def trainNN():
def predictNN():
etc. The neural network is constructed with Tensorflow, hence, the class definition and its methods use tensorflow syntax.
Now in the main part of my script, I create an instance of this class via
model = NeuralNetwork(...)
and use the methods of model such as model.predict to produce plots.
Since training the neural network takes long, I'd like to save the object "model" for future use and with the possibility to call on its methods. I have tried pickle and dill but they both failed. For pickle, I got the error:
TypeError: can't pickle _thread.RLock objects
while for dill, I got:
TypeError: can't pickle SwigPyObject objects
Any suggestions how I can save the object and still be able to invoke its methods? This is essential as I may want to perform prediction on a different set of points in the future.
Thanks!