titanic.py 文件源码

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

项目:tensorflow 作者: KirovVerst 项目源码 文件源码
def next_batch(df, i=None):
    """

    :param df: pandas dataframe
    :param i: batch index
    :return: (numpy array x, numpy array y)
    """
    if i is None:
        start = 0
        end = df.shape[0]
    else:
        start = BATCH_SIZE * i
        end = BATCH_SIZE * (i + 1)
    result = df[start:end]
    if "Survived" in result:
        batch_ys = pd.get_dummies(result.pop('Survived').values).as_matrix()
        batch_xs = result.as_matrix()
        return batch_xs, batch_ys
    else:
        return result.as_matrix()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号