(self, layer_shape, anchor_scale, extra_anchor_scale, anchor_ratio, layer_step, offset = 0.5)
return y_on_image, x_on_image, tf.constant(list_h_on_image, dtype=tf.float32), tf.constant(list_w_on_image, dtype=tf.float32), num_anchors
assume layer_shape[0] = 6, layer_shape[1] = 5
        x_on_layer = [[0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4]]
        y_on_layer = [[0, 0, 0, 0, 0],
                       [1, 1, 1, 1, 1],
                       [2, 2, 2, 2, 2],
                       [3, 3, 3, 3, 3],
                       [4, 4, 4, 4, 4],
                       [5, 5, 5, 5, 5]]
assume layer_shape[0] = 6, layer_shape[1] = 5
        x_on_layer = [[0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4]]
        y_on_layer = [[0, 0, 0, 0, 0],
                       [1, 1, 1, 1, 1],
                       [2, 2, 2, 2, 2],
                       [3, 3, 3, 3, 3],
                       [4, 4, 4, 4, 4],
                       [5, 5, 5, 5, 5]]
assume layer_shape [ 0 ] = 6 layer_shape [ 1 ] = 5 x_on_layer = [[ 0 1 2 3 4 ] [ 0 1 2 3 4 ] [ 0 1 2 3 4 ] [ 0 1 2 3 4 ] [ 0 1 2 3 4 ] [ 0 1 2 3 4 ]] y_on_layer = [[ 0 0 0 0 0 ] [ 1 1 1 1 1 ] [ 2 2 2 2 2 ] [ 3 3 3 3 3 ] [ 4 4 4 4 4 ] [ 5 5 5 5 5 ]]
def get_layer_anchors(self, layer_shape, anchor_scale, extra_anchor_scale, anchor_ratio, layer_step, offset = 0.5):
        ''' assume layer_shape[0] = 6, layer_shape[1] = 5
        x_on_layer = [[0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4],
                       [0, 1, 2, 3, 4]]
        y_on_layer = [[0, 0, 0, 0, 0],
                       [1, 1, 1, 1, 1],
                       [2, 2, 2, 2, 2],
                       [3, 3, 3, 3, 3],
                       [4, 4, 4, 4, 4],
                       [5, 5, 5, 5, 5]]
        '''
        x_on_layer, y_on_layer = tf.meshgrid(tf.range(layer_shape[1]), tf.range(layer_shape[0]))

        y_on_image = (tf.cast(y_on_layer, tf.float32) + offset) * layer_step / self._img_shape[0]
        x_on_image = (tf.cast(x_on_layer, tf.float32) + offset) * layer_step / self._img_shape[1]

        num_anchors = len(anchor_scale) * len(anchor_ratio) + len(extra_anchor_scale)

        #x_on_image = tf.Print(x_on_image, [x_on_layer], message='x_on_layer: ', summarize=1000)
        #y_on_image = tf.Print(y_on_image, [y_on_layer], message='y_on_layer: ', summarize=1000)

        list_h_on_image = []
        list_w_on_image = []

        global_index = 0
        for _, scale in enumerate(extra_anchor_scale):
            # h_on_image[global_index] = scale
            # w_on_image[global_index] = scale
            list_h_on_image.append(scale)
            list_w_on_image.append(scale)
            global_index += 1
        for scale_index, scale in enumerate(anchor_scale):
            for ratio_index, ratio in enumerate(anchor_ratio):
                # h_on_image[global_index] = scale  / math.sqrt(ratio)
                # w_on_image[global_index] = scale  * math.sqrt(ratio)
                list_h_on_image.append(scale / math.sqrt(ratio))
                list_w_on_image.append(scale * math.sqrt(ratio))
                global_index += 1
        # shape:
        # y_on_image, x_on_image: layers_shapes[0] * layers_shapes[1]
        # h_on_image, w_on_image: num_anchors
        return y_on_image, x_on_image, tf.constant(list_h_on_image, dtype=tf.float32), tf.constant(list_w_on_image, dtype=tf.float32), num_anchors
def get_layer_anchors ( self , layer_shape , anchor_scale , extra_anchor_scale , anchor_ratio , layer_step , offset = 0.5 ) : x_on_layer , y_on_layer = tf . meshgrid ( tf . range ( layer_shape [ 1 ] ) , tf . range ( layer_shape [ 0 ] ) ) y_on_image = ( tf . cast ( y_on_layer , tf . float32 ) + offset ) * layer_step / self . _img_shape [ 0 ] x_on_image = ( tf . cast ( x_on_layer , tf . float32 ) + offset ) * layer_step / self . _img_shape [ 1 ] num_anchors = len ( anchor_scale ) * len ( anchor_ratio ) + len ( extra_anchor_scale ) #x_on_image = tf.Print(x_on_image, [x_on_layer], message='x_on_layer: ', summarize=1000) #y_on_image = tf.Print(y_on_image, [y_on_layer], message='y_on_layer: ', summarize=1000) list_h_on_image = [ ] list_w_on_image = [ ] global_index = 0 for _ , scale in enumerate ( extra_anchor_scale ) : # h_on_image[global_index] = scale # w_on_image[global_index] = scale list_h_on_image . append ( scale ) list_w_on_image . append ( scale ) global_index += 1 for scale_index , scale in enumerate ( anchor_scale ) : for ratio_index , ratio in enumerate ( anchor_ratio ) : # h_on_image[global_index] = scale  / math.sqrt(ratio) # w_on_image[global_index] = scale  * math.sqrt(ratio) list_h_on_image . append ( scale / math . sqrt ( ratio ) ) list_w_on_image . append ( scale * math . sqrt ( ratio ) ) global_index += 1 # shape: # y_on_image, x_on_image: layers_shapes[0] * layers_shapes[1] # h_on_image, w_on_image: num_anchors return y_on_image , x_on_image , tf . constant ( list_h_on_image , dtype = tf . float32 ) , tf . constant ( list_w_on_image , dtype = tf . float32 ) , num_anchors