我正在使用Python 3.7.7。和张量流 2.1.0。
我是新手。
我有 N 个具有形状的张量(1, 12, 12, 512),我想对每个数组求和以获得具有相同形状的张量(1, 12, 12, 512)。然后除以N。
这些张量是编码器的输出,摘要如下:
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) [(None, 200, 200, 1)] 0
_________________________________________________________________
conv1_1 (Conv2D) (None, 200, 200, 64) 1664
_________________________________________________________________
conv1_2 (Conv2D) (None, 200, 200, 64) 102464
_________________________________________________________________
pool1 (MaxPooling2D) (None, 100, 100, 64) 0
_________________________________________________________________
conv2_1 (Conv2D) (None, 100, 100, 96) 55392
_________________________________________________________________
conv2_2 (Conv2D) (None, 100, 100, 96) 83040
_________________________________________________________________
pool2 (MaxPooling2D) (None, 50, 50, 96) 0
_________________________________________________________________
conv3_1 (Conv2D) (None, 50, 50, 128) 110720
_________________________________________________________________
conv3_2 (Conv2D) (None, 50, 50, 128) 147584
_________________________________________________________________
pool3 (MaxPooling2D) (None, 25, 25, 128) 0
_________________________________________________________________
conv4_1 (Conv2D) (None, 25, 25, 256) 295168
我一直在寻找,但我只找到了tf.math.reduce_mean并且我认为它没有做我想做的事。
我该怎么做?
更新:
我想我可以使用tf.math.add_n对所有张量求和,然后将结果张量除以 N。但我不确定。
阿晨1998
相关分类