矩阵变形是常用的操作,在Tensorflow中调用方式有多种,例如:
1. tf.reshape
tf.reshape(L3, [-1, W4.get_shape().as_list()[0]])
2. object.reshape
mnist.test.images.reshape(-1, 28, 28, 1)
所有reshape函数中,关键的是shape这个参数
下以tf.reshape为例介绍shape参数对结果的影响
tf.reshape(tensor, shape, name=None)
# tensor 't' is [1, 2, 3, 4, 5, 6, 7, 8, 9]
# tensor 't' has shape [9]
reshape(t, [3, 3]) ==> [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
# tensor 't' is [[[1, 1], [2, 2]],
# [[3, 3], [4, 4]]]
# tensor 't' has shape [2, 2, 2]
reshape(t, [2, 4]) ==> [[1, 1, 2, 2],
[3, 3, 4, 4]]
#