def find_max_location(scoremap):
    ' Returns the coordinates of the given scoremap with maximum value. '
    with tf.variable_scope('find_max_location'):
        s = scoremap.get_shape().as_list()
        if (len(s) == 4):
            scoremap = tf.squeeze(scoremap, [3])
        if (len(s) == 2):
            scoremap = tf.expand_dims(scoremap, 0)
        s = scoremap.get_shape().as_list()
        assert (len(s) == 3), 'Scoremap must be 3D.'
        assert ((s[0] < s[1]) and (s[0] < s[2])), 'Scoremap must be [Batch, Width, Height]'
        x_range = tf.expand_dims(tf.range(s[1]), 1)
        y_range = tf.expand_dims(tf.range(s[2]), 0)
        X = tf.tile(x_range, [1, s[2]])
        Y = tf.tile(y_range, [s[1], 1])
        x_vec = tf.reshape(X, [(- 1)])
        y_vec = tf.reshape(Y, [(- 1)])
        scoremap_vec = tf.reshape(scoremap, [s[0], (- 1)])
        max_ind_vec = tf.cast(tf.argmax(scoremap_vec, dimension=1), tf.int32)
        xy_loc = list()
        for i in range(s[0]):
            x_loc = tf.reshape(x_vec[max_ind_vec[i]], [1])
            y_loc = tf.reshape(y_vec[max_ind_vec[i]], [1])
            xy_loc.append(tf.concat([x_loc, y_loc], 0))
        xy_loc = tf.stack(xy_loc, 0)
        return xy_loc
Returns the coordinates of the given scoremap with maximum value.
def find_max_location(scoremap):
    '  '
    with tf.variable_scope('find_max_location'):
        s = scoremap.get_shape().as_list()
        if (len(s) == 4):
            scoremap = tf.squeeze(scoremap, [3])
        if (len(s) == 2):
            scoremap = tf.expand_dims(scoremap, 0)
        s = scoremap.get_shape().as_list()
        assert (len(s) == 3), 'Scoremap must be 3D.'
        assert ((s[0] < s[1]) and (s[0] < s[2])), 'Scoremap must be [Batch, Width, Height]'
        x_range = tf.expand_dims(tf.range(s[1]), 1)
        y_range = tf.expand_dims(tf.range(s[2]), 0)
        X = tf.tile(x_range, [1, s[2]])
        Y = tf.tile(y_range, [s[1], 1])
        x_vec = tf.reshape(X, [(- 1)])
        y_vec = tf.reshape(Y, [(- 1)])
        scoremap_vec = tf.reshape(scoremap, [s[0], (- 1)])
        max_ind_vec = tf.cast(tf.argmax(scoremap_vec, dimension=1), tf.int32)
        xy_loc = list()
        for i in range(s[0]):
            x_loc = tf.reshape(x_vec[max_ind_vec[i]], [1])
            y_loc = tf.reshape(y_vec[max_ind_vec[i]], [1])
            xy_loc.append(tf.concat([x_loc, y_loc], 0))
        xy_loc = tf.stack(xy_loc, 0)
        return xy_loc