def make_idx_data_cv(revs, word_idx_map, cv, max_l=51, k=100, filter_h=5):
"""
Transforms sentences into a 2-d matrix.
"""
train, test = [], []
for rev in revs:
sent = get_idx_from_sent(rev["text"], word_idx_map, max_l, k, filter_h)
sent.append(rev["y"])
if rev["split"]==cv:
test.append(sent)
else:
train.append(sent)
train = np.array(train,dtype="int")
train = np.random.permutation(train)[:10000]
test = np.array(test,dtype="int")
test = np.random.permutation(test)[:10000]
return [train, test]
conv_net_sentence.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录