data_helpers.py 文件源码

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

项目:reuters-classifier 作者: dmednis 项目源码 文件源码
def load_data_and_labels():

    articles = np.load('data/bin/all_articles.npy')
    labels = np.load('data/bin/all_labels.npy')

    articles = [clean_str(article) for article in articles]

    # Map the actual labels to one hot labels
    label_list = sorted(list(set(labels)))
    one_hot = np.zeros((len(label_list), len(label_list)), int)
    np.fill_diagonal(one_hot, 1)
    label_dict = dict(zip(label_list, one_hot))

    labels = one_hot_encode(labels, label_dict)

    x_raw = articles
    y_raw = labels
    return x_raw, y_raw, label_list
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号