-
LSTMCell,长短记忆单元
API说明: https://tensorflow.google.cn/versions/r1.9/api_docs/python/tf/contrib/rnn/LSTMCell
论文:http://www.bioinf.jku.at/publications/older/2604.pdfcell = tf.contrib.rnn.LSTMCell(size) #输入输出的shape不变
-
GRUCell,lstm变种,训练更快
API: https://tensorflow.google.cn/versions/r1.9/api_docs/python/tf/contrib/rnn/GRUCellcell = tf.contrib.rnn.GRUCell(size)
-
dynamic_rnn,灵活的创建一个rnn连接
API:https://tensorflow.google.cn/versions/r1.9/api_docs/python/tf/nn/dynamic_rnn
define in tensorflow/python/ops/rnn.pyoutput, _ = tf.nn.dynamic_rnn(LSTMCell(10), inputs=input_tensors, dtype=tf.float32, sequence_length=seq_length)# seq_length: An int32/int64 vector sized [batch_size],主要是为了性能,不影响正确性,对0位置的不做训练
-
get_variable,初始化或者创建一个变量
embedding = tf.get_variable("embedding", dtype=float32, shape=emb_shape, initializer=tf.contrib.layers.xavier_initializer())
initiallizer可以是一个object或者tensor,如果是tensor,那么shape是必须知道的
-
xavier_initializer,一个初始化对象
tf.contrib.layers.xavier_initializer(uniform=True,seed=None, dtype=tf.float32)
目的是让所有层的梯度大致相同,
论文:http://proceedings.mlr.press/v9/glorot10a/glorot10a.pdf
tensorfow笔记
最新推荐文章于 2024-04-22 16:37:06 发布