资源简介
git上的资源,可以用于自动创作诗,歌,小说等,数据集的话根据自己的需求去找,网上很多的
代码片段和文件信息
import tensorflow as tf
from tensorflow.contrib import rnn
from tensorflow.contrib import legacy_seq2seq
import numpy as np
class Model():
def __init__(self args training=True):
self.args = args
if not training:
args.batch_size = 1
args.seq_length = 1
# choose different rnn cell
if args.model == ‘rnn‘:
cell_fn = rnn.RNNCell
elif args.model == ‘gru‘:
cell_fn = rnn.GRUCell
elif args.model == ‘lstm‘:
cell_fn = rnn.LSTMCell
elif args.model == ‘nas‘:
cell_fn = rnn.NASCell
else:
raise Exception(“model type not supported: {}“.format(args.model))
# warp multi layered rnn cell into one cell with dropout
cells = []
for _ in range(args.num_layers):
cell = cell_fn(args.rnn_size)
if training and (args.output_keep_prob < 1.0 or args.input_keep_prob < 1.0):
cell = rnn.DropoutWrapper(cell
input_keep_prob=args.input_keep_prob
output_keep_prob=args.output_keep_prob)
cells.append(cell)
self.cell = cell = rnn.MultiRNNCell(cells state_is_tuple=True)
# input/target data (int32 since input is char-level)
self.input_data = tf.placeholder(
tf.int32 [args.batch_size args.seq_length])
self.targets = tf.placeholder(
tf.int32 [args.batch_size args.seq_length])
self.initial_state = cell.zero_state(args.batch_size tf.float32)
# softmax output layer use softmax to classify
with tf.variable_scope(‘rnnlm‘):
softmax_w = tf.get_variable(“softmax_w“
[args.rnn_size args.vocab_size])
softmax_b = tf.get_variable(“softmax_b“ [args.vocab_size])
# transform input to embedding
embedding = tf.get_variable(“embedding“ [args.vocab_size args.rnn_size])
inputs = tf.nn.embedding_lookup(embedding self.input_data)
# dropout beta testing: double check which one should affect next line
if training and args.output_keep_prob:
inputs = tf.nn.dropout(inputs args.output_keep_prob)
# unstack the input to fits in rnn model
inputs = tf.split(inputs args.seq_length 1)
inputs = [tf.squeeze(input_ [1]) for input_ in inputs]
# loop function for rnn_decoder which take the previous i-th cell‘s output and generate the (i+1)-th cell‘s input
def loop(prev _):
prev = tf.matmul(prev softmax_w) + softmax_b
prev_symbol = tf.stop_gradient(tf.argmax(prev 1))
return tf.nn.embedding_lookup(embedding prev_symbol)
# rnn_decoder to generate the ouputs and final state. When we are not training the model we use the loop function.
outputs last_state = legacy_seq2seq.rnn_decoder(inputs self.initial_st
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-11 22:55 char-rnn-tensorflow-master\
文件 1113 2018-05-11 22:55 char-rnn-tensorflow-master\.gitignore
文件 1377 2018-05-11 22:55 char-rnn-tensorflow-master\.travis.yml
文件 1080 2018-05-11 22:55 char-rnn-tensorflow-master\LICENSE.md
文件 3622 2018-05-11 22:55 char-rnn-tensorflow-master\README.md
目录 0 2018-05-11 22:55 char-rnn-tensorflow-master\data\
目录 0 2018-05-11 22:55 char-rnn-tensorflow-master\data\tinyshakespeare\
文件 1115394 2018-05-11 22:55 char-rnn-tensorflow-master\data\tinyshakespeare\input.txt
目录 0 2018-05-11 22:55 char-rnn-tensorflow-master\logs\
文件 71 2018-05-11 22:55 char-rnn-tensorflow-master\logs\.gitignore
文件 5639 2018-05-11 22:55 char-rnn-tensorflow-master\model.py
文件 1732 2018-05-11 22:55 char-rnn-tensorflow-master\sample.py
目录 0 2018-05-11 22:55 char-rnn-tensorflow-master\save\
文件 71 2018-05-11 22:55 char-rnn-tensorflow-master\save\.gitignore
文件 7542 2018-05-11 22:55 char-rnn-tensorflow-master\train.py
文件 3321 2018-05-11 22:55 char-rnn-tensorflow-master\utils.py
- 上一篇:昆明理工大学创新实践大报告
- 下一篇:基于改进的遗传算法的城市交通信号优化分析
相关资源
- LCSTS高质量中文短文本摘要数据集
- 情感词极值表,台湾大学NTUSD简体中文
- 台湾大学NTUSD简体中文情感词典+知网
- 人民日报2014语料库(全)
- 中文维基百科语料库百度网盘网址.
- 哈工大深圳NLP考试参考
- 中文基础情感词典(NTUSD/HowNet/Tsingh
- 自然语言处理、文本挖掘论文40篇 包
- people_daily_2014_corpus.zip
- 中文垃圾短信数据集NLP
- ChineseGLUE_lcqmc.zip
- NLPCC2014 微博情感分析样例数据
- 2016年国科大NLP自然语言处理期末考试
- 来自于NLPCC2013,解析成txt文件 不均衡
- Deep Learning for NLP and Speech Recognition.p
- 基于深度学习的自然语言处理 英文版
- 中文文本情感分类已标注
- 用RNN与LSTM网络原理进行唐诗生成.ta
- Chinese NER data MSRA 中文命名实体识别语
- Bert-Chinese-Text-Classification-Pytorch-maste
- THE INNER WORKINGS OF WORD2VEC
- wikiqa 数据集
- 蚂蚁金服文本匹配竞赛训练数据
- Reinforcement Learning in Natural Language Pro
- 自然语言处理技术
- 哈工大 同义词词林
- NLPCC2014情感分类语料集+已经标注好
- 已预处理 NLP 英文语料库 新闻组 20
- 中文NLP命名实体识别序列标注工具Y
- Natural Language Processing with PyTorch - 201
评论
共有 条评论