tensorflow 之 tf.reshape 之 -1
生活随笔
收集整理的這篇文章主要介紹了
tensorflow 之 tf.reshape 之 -1
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
最近壓力好大,寫點東西可能對心情有好處。
reshape即把矩陣的形狀變一下,這跟matlab一樣的,但如果參數是-1的話是什么意思呢?
看一下例子哈:
. . . In?[21]: ? tensor = tf.constant([1, 2, 3, 4, 5, 6, 7,8]) . . . In?[22]: ? sess.run(tf.initialize_all_variables()) . . . In?[23]: print(sess.run(tensor)) ? print(sess.run(tensor)) [1 2 3 4 5 6 7 8] . . . In?[24]: ? tensorReshape = tf.reshape(tensor,[2,4]) . . . In?[25]: ? print(sess.run(tensorReshape)) [[1 2 3 4][5 6 7 8]] . . . In?[26]: ? tensorReshape = tf.reshape(tensor,[1,2,4]) . . . In?[27]: ? print(sess.run(tensorReshape)) [[[1 2 3 4][5 6 7 8]]] . . . In?[28]: tensorResha ? tensorReshape = tf.reshape(tensor,[-1,2,2]) . . . In?[29]: ? print(sess.run(tensorReshape)) [[[1 2][3 4]][[5 6][7 8]]]所以-1,就是缺省值,就是先以你們合適,到時總數除以你們幾個的乘積,我該是幾就是幾。
. . .
轉載于:https://www.cnblogs.com/wasss/p/5439363.html
總結
以上是生活随笔為你收集整理的tensorflow 之 tf.reshape 之 -1的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Activiti工作流的应用示例
- 下一篇: Date 和 SimpleDateFor