Sorry, I have no reputation to comment, but I think you should take a look at the answer here: Keras, sparse matrix problem . I tried this and it works correctly, only one note, although at least in my case the shuffling led to really bad results, so I used this slightly modified alternative:
def nn_batch_generator(X_data, y_data, batch_size):
samples_per_epoch = X_data.shape[0]
number_of_batches = samples_per_epoch/batch_size
counter=0
index = np.arange(np.shape(y_data)[0])
while 1:
index_batch = index[batch_size*counter:batch_size*(counter+1)]
X_batch = X_data[index_batch,:].todense()
y_batch = y_data[index_batch]
counter += 1
yield np.array(X_batch),y_batch
if (counter > number_of_batches):
counter=0
, keras shuffled ( shuffle=True fit).