国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

經(jīng)典的把一篇英文文章轉(zhuǎn)成word2id形式的dict的一段python程序

2019-11-06 08:26:20
字體:
供稿:網(wǎng)友
import collectionsimport tensorflow as tfdef _read_Words(filename): with tf.gfile.GFile(filename, "r") as f: return f.read().decode("utf-8").replace("/n", "<eos>").split()def _build_vocab(filename): data = _read_words(filename) counter = collections.Counter(data) count_pairs = sorted(counter.items(), key=lambda x: (-x[1], x[0])) words, _ = list(zip(*count_pairs)) word_to_id = dict(zip(words, range(len(words)))) return word_to_id

摘自https://github.com/tensorflow/models/blob/master/tutorials/rnn/ptb/reader.py


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 兰考县| 晋州市| 临潭县| 洪雅县| 和顺县| 桃园县| 连南| 科技| 康乐县| 峨山| 三江| 金阳县| 高台县| 宝鸡市| 越西县| 遂川县| 海安县| 平山县| 类乌齐县| 庄浪县| 鱼台县| 来安县| 明星| 达拉特旗| 德江县| 天气| 油尖旺区| 永兴县| 博罗县| 林芝县| 酉阳| 慈利县| 淮滨县| 商丘市| 黄大仙区| 邯郸县| 龙游县| 固镇县| 涪陵区| 措美县| 基隆市|