标签:squeeze code nbsp pre 一个 str div on() with
import tensorflow as tf a = tf.constant([[1, 2],[2,4]]) b = tf.expand_dims(a,1) with tf.Session() as sess: a_, b_ = sess.run([a, b])
结果:
a: (2,2)
b:(2,1,2)
import tensorflow as tf a = tf.constant([[1, 2],[2,4]]) b = tf.expand_dims(a,0) with tf.Session() as sess: a_, b_ = sess.run([a, b])
结果:
a: (2,2)
b:(1,2,2)
import tensorflow as tf a = tf.constant([[1, 2],[2,4]]) b = tf.expand_dims(a,2) with tf.Session() as sess: a_, b_ = sess.run([a, b])
结果:
a: (2,2)
b:(2,2,1)
降低维度
import tensorflow as tf a = tf.constant([[1, 2, 3]]) b = tf.squeeze(a) with tf.Session() as sess: a_, b_ = sess.run([a, b])
结果:
a: (1,3)
b:(3,)
标签:squeeze code nbsp pre 一个 str div on() with
原文地址:https://www.cnblogs.com/ai-learning-blogs/p/13377954.html