當前位置: 首頁>>代碼示例>>Python>>正文


Python keras.metrics方法代碼示例

本文整理匯總了Python中tensorflow.keras.metrics方法的典型用法代碼示例。如果您正苦於以下問題:Python keras.metrics方法的具體用法?Python keras.metrics怎麽用?Python keras.metrics使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.keras的用法示例。


在下文中一共展示了keras.metrics方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _init

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def _init(string_list, tf_funcs, custom_funcs, logger=None, **kwargs):
    """
    Helper for 'init_losses' or 'init_metrics'.
    Please refer to their docstrings.

    Args:
        string_list:  (list)   List of strings, each giving a name of a metric
                               or loss to use for training. The name should
                               refer to a function or class in either tf_funcs
                               or custom_funcs modules.
        tf_funcs:     (module) A Tensorflow.keras module of losses or metrics,
                               or a list of various modules to look through.
        custom_funcs: (module) A custom module or losses or metrics
        logger:       (Logger) A Logger object
        **kwargs:     (dict)   Parameters passed to all losses or metrics which
                               are represented by a class (i.e. not a function)

    Returns:
        A list of len(string_list) of initialized classes of losses or metrics
        or references to loss or metric functions.
    """
    initialized = []
    tf_funcs = ensure_list_or_tuple(tf_funcs)
    for func_or_class in ensure_list_or_tuple(string_list):
        modules_found = list(filter(None, [getattr(m, func_or_class, None)
                                           for m in tf_funcs]))
        if modules_found:
            initialized.append(modules_found[0])  # return the first found
        else:
            # Fall back to look in custom module
            initialized.append(getattr(custom_funcs, func_or_class))
    return initialized 
開發者ID:perslev,項目名稱:MultiPlanarUNet,代碼行數:34,代碼來源:utils.py

示例2: init_metrics

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def init_metrics(metric_string_list, logger=None, **kwargs):
    """
    Same as 'init_losses', but for metrics.
    Please refer to the 'init_losses' docstring.
    """
    return _init(
        metric_string_list, metrics, custom_metrics, logger, **kwargs
    ) 
開發者ID:perslev,項目名稱:MultiPlanarUNet,代碼行數:10,代碼來源:utils.py

示例3: __init__

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def __init__(self, metrics=None):
        # str -> MetricHistory
        self.metrics = {}
        self.register_metrics(metrics) 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:6,代碼來源:metrics_tracking.py

示例4: register_metrics

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def register_metrics(self, metrics=None):
        metrics = metrics or []
        for metric in metrics:
            self.register(metric.name) 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:6,代碼來源:metrics_tracking.py

示例5: register

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def register(self, name, direction=None):
        if self.exists(name):
            raise ValueError('Metric already exists: %s' % (name,))
        if direction is None:
            direction = infer_metric_direction(name)
            if direction is None:
                # Objective direction is handled separately, but
                # non-objective direction defaults to min.
                direction = 'min'
        self.metrics[name] = MetricHistory(direction) 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:12,代碼來源:metrics_tracking.py

示例6: update

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def update(self, name, value, step=0):
        value = float(value)
        if not self.exists(name):
            self.register(name)

        prev_best = self.metrics[name].get_best_value()
        self.metrics[name].update(value, step=step)
        new_best = self.metrics[name].get_best_value()

        improved = new_best != prev_best
        return improved 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:13,代碼來源:metrics_tracking.py

示例7: get_history

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def get_history(self, name):
        self._assert_exists(name)
        return self.metrics[name].get_history() 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:5,代碼來源:metrics_tracking.py

示例8: get_best_value

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def get_best_value(self, name):
        self._assert_exists(name)
        return self.metrics[name].get_best_value() 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:5,代碼來源:metrics_tracking.py

示例9: get_best_step

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def get_best_step(self, name):
        self._assert_exists(name)
        return self.metrics[name].get_best_step() 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:5,代碼來源:metrics_tracking.py

示例10: get_statistics

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def get_statistics(self, name):
        self._assert_exists(name)
        return self.metrics[name].get_statistics() 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:5,代碼來源:metrics_tracking.py

示例11: get_last_value

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def get_last_value(self, name):
        self._assert_exists(name)
        return self.metrics[name].get_last_value() 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:5,代碼來源:metrics_tracking.py

示例12: get_direction

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def get_direction(self, name):
        self._assert_exists(name)
        return self.metrics[name].direction 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:5,代碼來源:metrics_tracking.py

示例13: from_config

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def from_config(cls, config):
        instance = cls()
        instance.metrics = {
            name: MetricHistory.from_config(metric_history)
            for name, metric_history in config['metrics'].items()}
        return instance 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:8,代碼來源:metrics_tracking.py

示例14: to_proto

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def to_proto(self):
        return kerastuner_pb2.MetricsTracker(metrics={
            name: metric_history.to_proto()
            for name, metric_history in self.metrics.items()}) 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:6,代碼來源:metrics_tracking.py

示例15: from_proto

# 需要導入模塊: from tensorflow import keras [as 別名]
# 或者: from tensorflow.keras import metrics [as 別名]
def from_proto(cls, proto):
        instance = cls()
        instance.metrics = {
            name: MetricHistory.from_proto(metric_history)
            for name, metric_history in proto.metrics.items()}
        return instance 
開發者ID:keras-team,項目名稱:keras-tuner,代碼行數:8,代碼來源:metrics_tracking.py


注:本文中的tensorflow.keras.metrics方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。