0
votes

I am working on a project involving neural machine translation (translating English to French).

I have worked through some examples online, and have now finished the model. Once a model is trained using Keras, how do I then get a prediction of a translation without training the entire model again, because with the large dataset I am using, each epoch takes some time and of course, I can't train the model every time I want a translation.

So what is the correct way of then generating predictions on new inputs without training the whole model again?

Thanks

enter image description here

enter image description here

2
You should add some code, because here you have people guessing what your code does. - Dr. Snoopy
Hi there, I have added some pictures. As can be seen in the first, I saved my model as "saved_weight.hdf5", and I then load them into "modelPred". Then in the "translate" function, I use the predict function but get the error above. - Trey Collier

2 Answers

1
votes

You need to save your model the model and its weights when the fit ends using :

keras.model.save(model_name)

At any time, you can load your trained model using

model = keras.load(model_name)

then perform predictions as

y_pred = model.predict(x_test)

Hope this will be helpful

0
votes

You can use the .predict() function which you can pass new inputs into it and it give you a prediction. The docs for this function are here: keras