Python 3.x 检查失败:iz%kz==0(256对0)输入通道256不是过滤器通道512的倍数
我正在实现以下代码,即网络模块中的CBAM模块,但是,我得到以下错误: F tensorflow/core/grappler/costs/op_level_cost_estimator.cc:654]检查失败:iz%kz==0(256对0)输入通道256不是滤波器通道512的倍数 这是CBAM块的代码Python 3.x 检查失败:iz%kz==0(256对0)输入通道256不是过滤器通道512的倍数,python-3.x,tensorflow,Python 3.x,Tensorflow,我正在实现以下代码,即网络模块中的CBAM模块,但是,我得到以下错误: F tensorflow/core/grappler/costs/op_level_cost_estimator.cc:654]检查失败:iz%kz==0(256对0)输入通道256不是滤波器通道512的倍数 这是CBAM块的代码 import tensorflow as tf def CBAM(input, reduction): """ @Convolutional Blo
import tensorflow as tf
def CBAM(input, reduction):
"""
@Convolutional Block Attention Module
"""
_, channel, width, height = input.get_shape() # (B, W, H, C)
input = tf.transpose(input, perm=[0, 3, 2, 1])
# channel attention
x_mean = tf.reduce_mean(input, axis=(1, 2), keepdims=True) # (B, 1, 1, C)
x_mean = tf.layers.conv2d(x_mean, channel // reduction, 1, activation=tf.nn.relu, name='CA1', reuse=tf.AUTO_REUSE) # (B, 1, 1, C // r)
x_mean = tf.layers.conv2d(x_mean, channel, 1, name='CA2', reuse=tf.AUTO_REUSE) # (B, 1, 1, C)
x_max = tf.reduce_max(input, axis=(1, 2), keepdims=True) # (B, 1, 1, C)
x_max = tf.layers.conv2d(x_max, channel // reduction, 1, activation=tf.nn.relu, name='CA1', reuse=tf.AUTO_REUSE)
# (B, 1, 1, C // r)
x_max = tf.layers.conv2d(x_max, channel, 1, name='CA2', reuse=tf.AUTO_REUSE) # (B, 1, 1, C)
x = tf.add(x_mean, x_max) # (B, 1, 1, C)
x = tf.nn.sigmoid(x) # (B, 1, 1, C)
x = tf.multiply(input, x) # (B, W, H, C)
# spatial attention
y_mean = tf.reduce_mean(x, axis=3, keepdims=True) # (B, W, H, 1)
y_max = tf.reduce_max(x, axis=3, keepdims=True) # (B, W, H, 1)
y = tf.concat([y_mean, y_max], axis=-1) # (B, W, H, 2)
y = tf.layers.conv2d(y, 1, 7, padding='same', activation=tf.nn.sigmoid) # (B, W, H, 1)
y = tf.multiply(x, y) # (B, W, H, C)
y = tf.transpose(y, perm=[0, 3, 2, 1])
return y
这里我调用了下面给出的网络中的CBAM()模块
layer17 = tf.layers.conv2d(layer16, 512, 3,
padding="same",
activation=tf.nn.relu,
dilation_rate=2,
data_format=self._data_format,
name="conv5/conv5_3")
layer17=CBAM(layer17, 8)
layer18 = tf.layers.max_pooling2d(layer17, 2, 1,
padding="same",
data_format=self._data_format)
如果有人能在以上代码中提供帮助,请!!!!