def _create_batches(self, X, batch_size, shuffle_data=False):
"""
Create batches out of a sequence of data.
This function will append zeros to the end of your data to ensure that
all batches are even-sized. These are masked out during training.
"""
if shuffle_data:
X = shuffle(X)
if batch_size > X.shape[0]:
batch_size = X.shape[0]
max_x = int(np.ceil(X.shape[0] / batch_size))
# This line first resizes the data to
X = np.resize(X, (batch_size, max_x, X.shape[1]))
# Transposes it to (len(X) / batch_size, batch_size, data_dim)
return X.transpose((1, 0, 2))
评论列表
文章目录