if sys.getsizeof(X) > MAX_GPU_RAM:
nb_block = float(sys.getsizeof(X))/MAX_GPU_RAM
nb_sample = np.shape(X)[0]
interval_points = np.linspace(0,nb_sample,nb_block+1).astype(int)
y_preds = []
for j in range(0,len(interval_points)-1):
indices = range(interval_points[j],interval_points[j+1])
y_preds.append(self.predict_on_batch(X[indices,:]))
After Change
for (X, y, w, ids) in dataset.itershards():
nb_sample = np.shape(X)[0]
interval_points = np.linspace(
0, nb_sample, np.ceil(float(nb_sample)/batch_size)+1).astype(int)
y_preds = []
for j in range(0,len(interval_points)-1):
indices = range(interval_points[j],interval_points[j+1])