TensorFlow Micellany

  1. 當數據是一個數的時候,可以不管shape進行比較數據的大小,例如,下面的例子b和c的shape不同,但if條件語句的句子會被執行。
with tf.Session() as sess:
    a = tf.constant([[[[[[[[[[[[[[[[[[[2]]]]]]]]]]]]]]]]]]],dtype=tf.int32,name='a')
    print(a)
    b = [[[[a]]]]
    c = [[[[[[[[[[[[[[[[[2]]]]]]]]]]]]]]]]]
    c = [[[[[c]]]]]
    print(sess.run(b))
    print(c)
    if sess.run(b) == c:
        print('execution')  # 會執行此句

輸出結果:

Tensor("a_13:0", shape=(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), dtype=int32)
[[[[array([[[[[[[[[[[[[[[[[[[2]]]]]]]]]]]]]]]]]]], dtype=int32)]]]]
[[[[[[[[[[[[[[[[[[[[[[2]]]]]]]]]]]]]]]]]]]]]]
execution
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章