The trained kera model makes its predictions much more slowly than in training

I trained the keras model in one night and got 75% accuracy, which I am pleased with right now. It has 60,000 samples, each of which has a length of about 700 and a vocabulary of 30. Each era takes about 10 minutes on my gpu. So it's 60,000/600 seconds, which is about 100 samples per second, and this should include backpropagation. So I saved my hdf5 file and downloaded it again.

<code>#Model:
model = Sequential() 
model.add(LSTM(128, input_shape=(X.shape[1], X.shap[2]), return_sequences=True)) model.add(Dropout(0.25)) model.add(LSTM(64)) model.add(Dropout(0.25)) model.add(Dense(y.shape[1], activation='softmax'))
</code>

When I make my predictions, it takes more than 1 second for a forecast that is 100 times slower than training. The forecasts are good, I looked at small batches, and I can use them. The problem is that I need a lot of 100,000 of them. 10 ms for each forecast will work, 1 second will not.

Can anyone suggest ways to speed up Keras predictions?

+4
source share

Source: https://habr.com/ru/post/1664932/


All Articles