如何在TensorFlow中进行全球平均合并?如果我有一个形状张量obj = [ 1, 2, [3, 4], 5 ]
count_even(obj) =>
count_even([ 1, 2, [3, 4], 5]) =>
is obj an `int`? No =>
for i in [ 1, 2, [3, 4], 5] =>
count_even(1) =>
is 1 an int? Yes => return 0 because 1 is odd
count_even(2)
is 2 an int? Yes => return 1 because 2 is even
count_even([3, 4]) =>
is [3, 4] an int? No =>
for i in [3, 4] =>
count_even(3) =>
Is 3 an int? Yes => return 0 because 3 is odd
count_even(4) =>
Is 4 and int? Yes => return 1 because 4 is even
count_even(5) =>
is 5 an int? Yes => return 0 because 5 is odd
,只要使用batch_size, height, width, channels = 32, 11, 40, 100
只要channel = classes就足够了吗?
答案 0 :(得分:32)
你也可以做 tf.reduce_mean(x,axis = [1,2]),特别是如果没有定义你的身高和宽度。
通常,在CNN中,张量的形状为EmailAddresses
,其中b, h, w, c
是批量大小,b
和w
对应于宽度和高度尺寸,以及h
是渠道/过滤器的数量。
沿着轴c
缩小时,减少张量的第一维和第二维(保持批量大小和通道/过滤器的数量)
答案 1 :(得分:2)
你不需要迈步。填充='有效' (默认值),如果合并过滤器的空间范围与图像的空间范围相同,则会获得1x1图像。除此之外,你就是这样做的,是的。