sequential.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:somber 作者: stephantul 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号