Understanding Keras Lstm ( Lstm_text_generation.py ) - Ram Memory Issues
Solution 1:
There are at least two optimizations in Keras which you could use in order to decrease amount of memory which is need in this case:
An Embedding layer which makes it possible to accept only a single integer intead of full one hot vector. Moreover - this layer could be pretrained before the final stage of network training - so you could inject some prior knowledge into your model (and even finetune it during the network fitting).
A
fit_generator
method makes it possible to train a network using a predefinied generator which would produce pairs(x, y)
need in network fitting. You could e.g. save the whole dataset to disk and read it part by part using a generator interface.
Of course - both of this methods could be mixed. I think that simplicity was the reason behind this kind of implementation in the example you provided.
Post a Comment for "Understanding Keras Lstm ( Lstm_text_generation.py ) - Ram Memory Issues"