美文网首页
tensorflow学习笔记

tensorflow学习笔记

作者: 钢铁油腻男 | 来源:发表于2017-10-24 11:36 被阅读10次

    老旧tensorflow的api对比

    tf.nn.seq2seq.sequence_loss_by_example -> tf.contrib.legacy_seq2seq.sequence_loss_by_example
    tf.nn.rnn_cell -> tf.contrib.rnn
    

    tensorflow.Variable与 get_variable的区别

    简而言之, get_variable用户共享的变量, 所以使用了两次一模一样的参数的时候, 就会提示错误;
    而 tf.variable_scope("scope1", reuse=True)后, 下面再次出现一模一样的参数, 就会去那个共享的variable。

    import tensorflow as tf
    
    with tf.variable_scope("scope1"):
        w1 = tf.get_variable("w1", shape=[])
        w2 = tf.Variable(0.0, name="w2")
    with tf.variable_scope("scope1", reuse=True):
        w1_p = tf.get_variable("w1", shape=[])
        w2_p = tf.Variable(1.0, name="w2")
    
    print(w1 is w1_p, w2 is w2_p)
    #输出
    #True  False
    

    相关文章

      网友评论

          本文标题:tensorflow学习笔记

          本文链接:https://www.haomeiwen.com/subject/tylpuxtx.html