有人可以帮我吗?
File "C:\tensorflow1\models\research\slim\nets\mobilenet\mobilenet.py", line 397, in <module>
def global_pool(input_tensor, pool_op=tf.compat.v1.nn.avg_pool2d):
AttributeError: module 'tensorflow._api.v1.compat.v1.nn' has no attribute 'avg_pool2d'
这是代码
def global_pool(input_tensor, pool_op=tf.nn.avg_pool2d):
shape = input_tensor.get_shape().as_list()
if shape[1] is None or shape[2] is None:
kernel_size = tf.convert_to_tensor(
[1, tf.shape(input_tensor)[1],
tf.shape(input_tensor)[2], 1])
else:
kernel_size = [1, shape[1], shape[2], 1]
output = pool_op(
input_tensor, ksize=kernel_size, strides=[1, 1, 1, 1], padding='VALID')
# Recover output shape, for unknown shape.
output.set_shape([None, 1, 1, None])
return output
它应该是 tf.nn.avg_pool2d(...) 是这样的吗?我确实在寻找解决方案。但我真的不明白。