Tensorflow中是否有展开功能,其中矩阵被转换为矢量。
范例:
矩阵[1 2 3; 4 5 6;]被“展开”为向量[1 2 3 4 5 6]
查看数学运算,这似乎不可用:https : //www.tensorflow.org/versions/r0.12/api_docs/python/math_ops.html
tf.reshape(a, shape=[-1])将a使用行优先顺序将张量“展开” 到向量中。如果您想要其他订单,可以tf.transpose先
import tensorflow as tf
a = tf.constant([[1, 2, 3], [4, 5, 6]])
b = tf.reshape(a, shape=[-1])
sess = tf.Session()
sess.run(b) # => array([1, 2, 3, 4, 5, 6], dtype=int32)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2364 次 |
| 最近记录: |