def MetricLayer(metric_func):
    # Special care for accuracy because keras treats it specially
    if "accuracy" in metric_func:
        metric_func = generic_accuracy
    metric_func = compose(K.expand_dims, get_metric(metric_func))

    return Lambda(lambda inputs: metric_func(*inputs), output_shape=(None, 1))
Esempio n. 2
0
    def build(self, input_shape):
        # Special care for accuracy because keras treats it specially
        try:
            if "acc" in self.metric_func:
                self.metric_func = self._generic_accuracy
        except TypeError:
            pass  # metric_func is not a string
        self.metric_func = compose(K.expand_dims, get_metric(self.metric_func))

        super(MetricLayer, self).build(input_shape)