资源简介
RNN 文本分类 大作业 BASICRNN BASICLSTM GRU
RNN 文本分类 大作业 BASICRNN BASICLSTM GRU
代码片段和文件信息
import tensorflow as tf
def weight_variable(shape): # you can use this func to build new variables
or_init = tf.orthogonal_initializer()
#initial = tf.truncated_normal(shape stddev=0.01)
initial = or_init(shape)
return tf.Variable(initial)
def bias_variable(shape): # you can use this func to build new variables
initial = tf.constant(1.0 shape=shape)
return tf.Variable(initial)
class BasicRNNCell(tf.contrib.rnn.RNNCell):
def __init__(self num_units activation=tf.tanh reuse=None):
self._num_units = num_units
self._activation = activation
self._reuse = reuse
self._Wxh = weight_variable([300 self._num_units])
self._Whh = weight_variable([self._num_units self._num_units])
self._B = bias_variable([self._num_units])
@property
def state_size(self):
return self._num_units
@property
def output_size(self):
return self._num_units
def __call__(self inputs state scope=None):
with tf.variable_scope(scope or “basic_rnn_cell“ reuse=self._reuse):
#todo: implement the new_state calculation given inputs and state
self._linear = tf.matmul(inputs self._Wxh) + tf.matmul(state self._Whh) + self._B
new_state = self._activation(self._linear)
return new_state new_state
class GRUCell(tf.contrib.rnn.RNNCell):
‘‘‘Gated Recurrent Unit cell (http://arxiv.org/abs/1406.1078).‘‘‘
def __init__(self num_units activation=tf.tanh reuse=None):
self._num_units = num_units
self._activation = activation
self._reuse = reuse
self._Wxr = weight_variable([300 self._num_units])
self._Whr = weight_variable([self._num_units self._num_units])
self._br = bias_variable([self._num_units])
self._Wxz = weight_variable([300 self._num_units])
self._Whz = weight_variable([self._num_units self._num_units])
self._bz = bias_variable([self._num_units])
self._Wxh = weight_variable([300 self._num_units])
self._Whh = weight_variable([self._num_units self._num_units])
self._bh = bias_variable([self._num_units])
@property
def state_size(self):
return self._num_units
@property
def output_size(self):
return self._num_units
def __call__(self inputs state scope=None):
with tf.variable_scope(scope or “gru_cell“ reuse=self._reuse):
#We start with bias of 1.0 to not reset and not update.
#todo: implement the new_h calculation given inputs and state
r = tf.sigmoid(tf.matmul(inputs self._Wxr) + tf.matmul(state self._Whr) + self._br)
z = tf.sigmoid(tf.matmul(inputs self._Wxz) + tf.matmul(state self._Whz) + self._bz)
h1 = tf.tanh(tf.matmul(inputs self._Wxh) + tf.matmul(state * r self._Whh) + self._bh)
new_h = z * state + (1 - z) * h1
return new_h new_h
class BasicLSTMCell(tf.contrib
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-11-20 22:30 code\
文件 6148 2017-11-20 22:30 code\.DS_Store
目录 0 2017-11-20 22:30 __MACOSX\
目录 0 2017-11-20 22:30 __MACOSX\code\
文件 120 2017-11-20 22:30 __MACOSX\code\._.DS_Store
文件 5087 2017-11-20 20:14 code\cell.py
文件 212 2017-11-20 20:14 __MACOSX\code\._cell.py
目录 0 2017-10-30 21:07 code\data\
文件 117239 2017-10-30 21:01 code\data\dev.txt
目录 0 2017-11-20 22:30 __MACOSX\code\data\
文件 212 2017-10-30 21:01 __MACOSX\code\data\._dev.txt
文件 233634 2017-10-30 21:00 code\data\test.txt
文件 212 2017-10-30 21:00 __MACOSX\code\data\._test.txt
文件 902818 2017-10-30 21:00 code\data\train.txt
文件 212 2017-10-30 21:00 __MACOSX\code\data\._train.txt
文件 45628624 2017-10-30 21:01 code\data\vector.txt
文件 212 2017-10-30 21:07 __MACOSX\code\._data
文件 7639 2017-11-20 22:28 code\main.py
文件 328 2017-11-20 22:28 __MACOSX\code\._main.py
文件 5230 2017-11-20 22:29 code\model.py
文件 328 2017-11-20 22:29 __MACOSX\code\._model.py
文件 212 2017-11-20 22:30 __MACOSX\._code
文件 1292116 2017-11-20 20:11 report.pdf
相关资源
- foxmail.zip
- airServer 免激活版本
- AIX5.3、6.1、7.1可用的openssl0.9.8和open
- Amazon Sagemaker端到端的托管机器学习平
- BaiduCdp_1_0_1.zip
- Numerical Analysis - 9th - (Burden & Faires)
- 训练集与测试集数据train-images-idx3-u
-
《玩转.NET Micro fr
amework 移植-基于 - HP Array Configuration Utility 32位 64位
- Terrain to Mesh 2018.3
- Algebraic Topology [hatcher].
- Rainlendar专业版2.13.1----64bit,带licens
- Raize.6.2.3.Install.rar
- mnist数据资源processed中的training.pt
- Unity3D官方地形包,TerrainAsset.unitypac
- 吴恩达机器学习课程课件及程序完整
- 2018电赛 手势识别for MSP430F5529 oled图形
- IAI电缸软件RC联机
- 天池工业ai初赛数据集
- 基于ssm框架的人事管理系统
- LBP/HOG/SIFT/SURF特征SVM的trainAuto范例
- 自然场景OCR(YOLOv3+CRNN)
- eng.traineddata
- Syscalc6 射频连级仿真软件
- AirServer 7.2.0破解版 将Mac变成一个Air
- 清华大学、中国人工智能学会重磅发
- NI_Vision_Builder_AI入门教程 ( ni 视觉概
- e-hentai ios.ipa
- Probabilistic Graphical Models Principles and
- 统计学习(the element of statistical lear
评论
共有 条评论