我使用vector作为第二个参数来满足reduce_mean的用法。我查看了传感器流程手册,但无法找到相应的示例。代码如下:
tf.reduce_mean(train, [0,1,2]
其中火车的大小为批量x x x L x 2 我也玩了一些实验,但无法弄清楚第二个矢量输入将如何处理
tensor = tf.constant([[[2,2,4],[2,2,0]],[[2,2,0],[2,2,0]]])
trainenergy = tf.reduce_mean(tensor, [0,1,2])
Output = 1
tensor = tf.constant([[[2,2,4],[2,2,0]],[[2,2,0],[2,2,0]]])
trainenergy = tf.reduce_mean(tensor, [0])
Output = [[2 2 2]
[2 2 0]]
tensor = tf.constant([[[2,2,4],[2,2,0]],[[2,2,0],[2,2,0]]])
trainenergy = tf.reduce_mean(tensor, [0,1])
Output = [2 2 1]
答案 0 :(得分:1)
如果第二个参数是向量,只需找出tf.reduce_mean(train,[0,1,2])。它将减小尺寸,因为元素的顺序是向量。例如,[0,1,2]将沿着轴线0,1,2
减小