tensorfow笔记

  1. LSTMCell,长短记忆单元
    API说明: https://tensorflow.google.cn/versions/r1.9/api_docs/python/tf/contrib/rnn/LSTMCell
    论文:http://www.bioinf.jku.at/publications/older/2604.pdf

    cell = tf.contrib.rnn.LSTMCell(size)  #输入输出的shape不变
    
  2. GRUCell,lstm变种,训练更快
    API: https://tensorflow.google.cn/versions/r1.9/api_docs/python/tf/contrib/rnn/GRUCell

     cell = tf.contrib.rnn.GRUCell(size)
    
  3. dynamic_rnn,灵活的创建一个rnn连接
    API:https://tensorflow.google.cn/versions/r1.9/api_docs/python/tf/nn/dynamic_rnn
    define in tensorflow/python/ops/rnn.py

    output, _ = 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位置的不做训练
    
  4. get_variable,初始化或者创建一个变量

    embedding = tf.get_variable("embedding", dtype=float32, shape=emb_shape, initializer=tf.contrib.layers.xavier_initializer())
    

    initiallizer可以是一个object或者tensor,如果是tensor,那么shape是必须知道的

  5. xavier_initializer,一个初始化对象

    tf.contrib.layers.xavier_initializer(uniform=True,seed=None, dtype=tf.float32)
    

    目的是让所有层的梯度大致相同,
    论文:http://proceedings.mlr.press/v9/glorot10a/glorot10a.pdf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值