2

can some help me with this?

  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'

here's the code

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

it should be tf.nn.avg_pool2d(...) like this is it? i did search for solution. but i dont really understand it.

Nur Fe
  • 47
  • 1
  • 6

1 Answers1

2

Have you tried changing it to tf.nn.avg_pool? It seemed to work for me.

Meed223
  • 36
  • 2