prepro_ngrams.py 文件源码

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

项目:self-critical.pytorch 作者: ruotianluo 项目源码 文件源码
def main(params):

  imgs = json.load(open(params['input_json'], 'r'))
  itow = json.load(open(params['dict_json'], 'r'))['ix_to_word']
  wtoi = {w:i for i,w in itow.items()}

  imgs = imgs['images']

  ngram_words, ngram_idxs, ref_len = build_dict(imgs, wtoi, params)

  cPickle.dump({'document_frequency': ngram_words, 'ref_len': ref_len}, open(params['output_pkl']+'-words.p','w'), protocol=cPickle.HIGHEST_PROTOCOL)
  cPickle.dump({'document_frequency': ngram_idxs, 'ref_len': ref_len}, open(params['output_pkl']+'-idxs.p','w'), protocol=cPickle.HIGHEST_PROTOCOL)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号