How do I use the same memory address for redundant rows of numpy array?
The way I overcame my memory issue is by using fit_generator() instead of fit(). The generator function can take my more efficient list of lists structure and generate the (now much smaller) numpy array just-in-time for each batch, reducing the memory needed overall.
Another topic I ran into is sparse arrays. Because one-hot vector arrays contain a lot of zeros, they are sparse and it is much more efficient to store them as such e.g. with scipy's sparse matrix implementations. The generator function will again need to convert them to dense numpy arrays for fit_generator().
There is also a sparse tensor implemented in tf that should not require a generator to convert it to a dense array but I wasn't able to make it work.
I'm making an RNN language model with Keras and in order to train the model (supervised learning) I have to create a numpy array y (with the labels of each observation for each sequence) of shape (num_of_training_sequences, size_of_vocabulary) containing one-hot vectors.
When I have too many training sequences, this array is too big to fit in memory. However, it doesn't have to be! Since the number of possible one-hot vectors is only size_of_vocabulary, then y could just be a num_of_training_sequences sized array that contains references (aka pointers) to pre-allocated one-hot vectors. This way, if two sequences end in the same word and should have the same one-hot vector, then they would just reference the same address in memory of that one-hot vector. 
And everyone should be happy, except from numpy arrays. Because when I cast this magesticly efficient data structure to numpy array, it tries to allocate the whole array into memory, along with duplicate and reduntant one-hot vectors. 
Is there anything I can do to overcome this? Keras's code and documentation says fit() only accepts numpy arrays and tensors.