preprocess.py 文件源码

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

项目:AoAReader 作者: kevinkwl 项目源码 文件源码
def vectorize_stories(stories, vocab : Vocabulary):
    X = []
    Q = []
    C = []
    A = []

    for s, q, a, c in stories:
        x = vocab.convert2idx(s)
        xq = vocab.convert2idx(q)
        xc = vocab.convert2idx(c)
        X.append(x)
        Q.append(xq)
        C.append(xc)
        A.append(vocab.getIdx(a))

    X = X
    Q = Q
    C = C
    A = torch.LongTensor(A)
    return X, Q, A, C
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号