1
$\begingroup$

I am using tflearn to text classification. I am able to create DNN and fit it and save it and also retrieve it for predictions.

I would like to update trained model with new test data. I checked documentation and also methods but the only way I could figure out is to call

model.fit() which would completely retrain the model and takes a lot of time since it is from scratch.

On other hand model.save() would just save the loaded model without updating new data.

Is there a function or way to update the trained model with just one data without going through whole retraining process?

Code used to load and save model

model.fit(train_x, train_y, n_epoch=1000, batch_size=8, show_metric=True)
model.save('model.tflearn')

Code used to retrieve and load existing model

tf.reset_default_graph()
# Build neural network
# train_x[0] and train_y[0] had to be regenerated from scratch
net = tflearn.input_data(shape=[None, len(train_x[0])])
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, len(train_y[0]), activation='softmax')
net = tflearn.regression(net)

# Define model and setup tensorboard
dnn = tflearn.DNN(net, tensorboard_dir='tflearn_logs')
dnn.load('./model.tflearn')
$\endgroup$
2
  • $\begingroup$ Yes, but I dont think that model.predict(test_data) "retrains" or update the model, or am I wrong? $\endgroup$ – Kornel B. Sep 7 '18 at 21:05
  • $\begingroup$ Yes you are right . calling just predict wont retrain it. And it wont update the model . It just calls the predict function to make predictions. I missed some code which had in system . will check and post new answer $\endgroup$ – Morse Sep 7 '18 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.