nn/basicNetwork.py
def create_resetable_metric_single_iou(scope=tf.get_variable_scope().name, **kwargs):
        """
        Create resetable operations for iou metric, this metric will noly calculate iou for class 1
        :param metric: streaming metric function
        :param var_name: name of the metric variable
        :param scope: default to current scope name
        :param kwargs:
        :return:
        """
        def single_class_metric_fn(predictions=None, labels=None):
            vars = []
            tp, update_tp = tf.metrics.true_positives(labels=labels, predictions=predictions, name='tp')
            vars.append(tf.get_collection(tf.GraphKeys.LOCAL_VARIABLES, scope='{}/{}'.format(scope, 'tp'))[0])
            fn, update_fn = tf.metrics.false_negatives(labels=labels, predictions=predictions, name='fn')
            vars.append(tf.get_collection(tf.GraphKeys.LOCAL_VARIABLES, scope='{}/{}'.format(scope, 'fn'))[0])
            fp, update_fp = tf.metrics.false_positives(labels=labels, predictions=predictions, name='fp')
            vars.append(tf.get_collection(tf.GraphKeys.LOCAL_VARIABLES, scope='{}/{}'.format(scope, 'fp'))[0])

            return tp/(tp + fn + fp), tf.group(update_tp, update_fn, update_fp), vars

        assert kwargs['num_classes'] == 2
        metric_op, update_op, vars = single_class_metric_fn(predictions=kwargs['predictions'], labels=kwargs['labels'])
        reset_op = tf.variables_initializer(vars)
        return metric_op, update_op, reset_op

        Create resetable operations for iou metric, this metric will noly calculate iou for class 1
        :param metric: streaming metric function
        :param var_name: name of the metric variable
        :param scope: default to current scope name
        :param kwargs:
        :return:
        
Create resetable operations for iou metric, this metric will noly calculate iou for class 1
Create resetable operations for iou metric this metric will noly calculate iou for class 1
def create_resetable_metric_single_iou(scope=tf.get_variable_scope().name, **kwargs):
        def single_class_metric_fn(predictions=None, labels=None):
            vars = []
            tp, update_tp = tf.metrics.true_positives(labels=labels, predictions=predictions, name='tp')
            vars.append(tf.get_collection(tf.GraphKeys.LOCAL_VARIABLES, scope='{}/{}'.format(scope, 'tp'))[0])
            fn, update_fn = tf.metrics.false_negatives(labels=labels, predictions=predictions, name='fn')
            vars.append(tf.get_collection(tf.GraphKeys.LOCAL_VARIABLES, scope='{}/{}'.format(scope, 'fn'))[0])
            fp, update_fp = tf.metrics.false_positives(labels=labels, predictions=predictions, name='fp')
            vars.append(tf.get_collection(tf.GraphKeys.LOCAL_VARIABLES, scope='{}/{}'.format(scope, 'fp'))[0])
            return tp/(tp + fn + fp), tf.group(update_tp, update_fn, update_fp), vars
        assert kwargs['num_classes'] == 2
        metric_op, update_op, vars = single_class_metric_fn(predictions=kwargs['predictions'], labels=kwargs['labels'])
        reset_op = tf.variables_initializer(vars)
        return metric_op, update_op, reset_op
def create_resetable_metric_single_iou ( scope = tf . get_variable_scope ( ) . name , ** kwargs ) : def single_class_metric_fn ( predictions = None , labels = None ) : vars = [ ] tp , update_tp = tf . metrics . true_positives ( labels = labels , predictions = predictions , name = 'tp' ) vars . append ( tf . get_collection ( tf . GraphKeys . LOCAL_VARIABLES , scope = '{}/{}' . format ( scope , 'tp' ) ) [ 0 ] ) fn , update_fn = tf . metrics . false_negatives ( labels = labels , predictions = predictions , name = 'fn' ) vars . append ( tf . get_collection ( tf . GraphKeys . LOCAL_VARIABLES , scope = '{}/{}' . format ( scope , 'fn' ) ) [ 0 ] ) fp , update_fp = tf . metrics . false_positives ( labels = labels , predictions = predictions , name = 'fp' ) vars . append ( tf . get_collection ( tf . GraphKeys . LOCAL_VARIABLES , scope = '{}/{}' . format ( scope , 'fp' ) ) [ 0 ] ) return tp / ( tp + fn + fp ) , tf . group ( update_tp , update_fn , update_fp ) , vars assert kwargs [ 'num_classes' ] == 2 metric_op , update_op , vars = single_class_metric_fn ( predictions = kwargs [ 'predictions' ] , labels = kwargs [ 'labels' ] ) reset_op = tf . variables_initializer ( vars ) return metric_op , update_op , reset_op
Create resetable operations for iou metric, this metric will noly calculate iou for class 1
Create resetable operations for iou metric this metric will noly calculate iou for class 1
"""
        Create resetable operations for iou metric, this metric will noly calculate iou for class 1
        :param metric: streaming metric function
        :param var_name: name of the metric variable
        :param scope: default to current scope name
        :param kwargs:
        :return:
        """
None
scope
default to current scope name
default to current scope name
metric
streaming metric function
streaming metric function
var_name
name of the metric variable
name of the metric variable
kwargs
None