why not using np.array_split here?

for X_chunk in np.array_split(X, n_batches):
     rbm.partial_fit(X_chunk)