当前位置: 首页>>代码示例>>Python>>正文


Python metrics.get方法代码示例

本文整理汇总了Python中keras.metrics.get方法的典型用法代码示例。如果您正苦于以下问题:Python metrics.get方法的具体用法?Python metrics.get怎么用?Python metrics.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keras.metrics的用法示例。


在下文中一共展示了metrics.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: evaluate

# 需要导入模块: from keras import metrics [as 别名]
# 或者: from keras.metrics import get [as 别名]
def evaluate(self, inputs, fn_inverse=None, fn_plot=None):
        try:
            X, y = inputs
            inputs = X
        except:
            X, conditions, y = inputs
            inputs = [X, conditions]

        y_hat = self.predict(inputs)

        if fn_inverse is not None:
            y_hat = fn_inverse(y_hat)
            y = fn_inverse(y)

        if fn_plot is not None:
            fn_plot([y, y_hat])

        results = []
        for m in self.model.metrics:
            if isinstance(m, str):
                results.append(K.eval(K.mean(get(m)(y, y_hat))))
            else:
                results.append(K.eval(K.mean(m(y, y_hat))))
        return results 
开发者ID:albertogaspar,项目名称:dts,代码行数:26,代码来源:FFNN.py

示例2: evaluate

# 需要导入模块: from keras import metrics [as 别名]
# 或者: from keras.metrics import get [as 别名]
def evaluate(self, data, fn_inverse=None, fn_plot=None):
        try:
            X, y = data
            y_hat = self.predict(X)
        except:
            X, X_ex, y = data
            y_hat = self.predict([X, X_ex])

        if fn_inverse is not None:
            y = fn_inverse(y)
            y_hat = fn_inverse(y_hat)

        y = np.float32(y)
        y_hat = np.float32(y_hat)

        if fn_plot is not None:
            fn_plot([y, y_hat])

        results = []
        for m in self.model.metrics:
            if isinstance(m, str):
                results.append(K.eval(K.mean(get(m)(y, y_hat))))
            else:
                results.append(K.eval(K.mean(m(y, y_hat))))
        return results 
开发者ID:albertogaspar,项目名称:dts,代码行数:27,代码来源:TCN.py

示例3: __init__

# 需要导入模块: from keras import metrics [as 别名]
# 或者: from keras.metrics import get [as 别名]
def __init__(self,
                 layers,
                 activation=None,
                 use_bias=True,
                 kernel_initializer='glorot_uniform',
                 bias_initializer='zeros',
                 kernel_regularizer=None,
                 bias_regularizer=None,
                 activity_regularizer=None,
                 kernel_constraint=None,
                 bias_constraint=None,
                 dropout=0.0,
                 recursive_forecast=False,
                 ):
        """
        Base FeedForward Neural Network.

        :param layers: list of integers. The i-th elem. of the list is the number of units of the i-th layer.
        :param dropout: An integer or tuple/list of a single integer, specifying the length
            of the 1D convolution window.
        :param recursive_forecast: an integer or tuple/list of a single integer, specifying the dilation rate
            to use for dilated convolution.
            Usually dilation rate increases exponentially with the depth of the network.
        :param for all the other parameters see keras.layers.Dense
        """
        self.layers = layers
        self.dropout = dropout
        self.activation = activations.get(activation)
        self.use_bias = use_bias
        self.kernel_initializer = initializers.get(kernel_initializer)
        self.bias_initializer = initializers.get(bias_initializer)
        self.kernel_regularizer = regularizers.get(kernel_regularizer)
        self.bias_regularizer = regularizers.get(bias_regularizer)
        self.activity_regularizer = regularizers.get(activity_regularizer)
        self.kernel_constraint = constraints.get(kernel_constraint)
        self.bias_constraint = constraints.get(bias_constraint)
        self.recursive_forecast = recursive_forecast
        self.model = None
        self.horizon = None 
开发者ID:albertogaspar,项目名称:dts,代码行数:41,代码来源:FFNN.py

示例4: _eval

# 需要导入模块: from keras import metrics [as 别名]
# 或者: from keras.metrics import get [as 别名]
def _eval(self, y, y_hat):
        results = []
        for m in self.model.metrics:
            if isinstance(m, str):
                results.append(K.eval(K.mean(get(m)(y, y_hat))))
            else:
                results.append(K.eval(K.mean(m(y, y_hat))))
        return results 
开发者ID:albertogaspar,项目名称:dts,代码行数:10,代码来源:Recurrent.py

示例5: _build_encoder

# 需要导入模块: from keras import metrics [as 别名]
# 或者: from keras.metrics import get [as 别名]
def _build_encoder(self):
        """
        Build the encoder multilayer RNN (stacked RNN)
        """
        # Create a list of RNN Cells, these get stacked one after the other in the RNN,
        # implementing an efficient stacked RNN
        encoder_cells = []
        for n_hidden_neurons in self.encoder_layers:
            encoder_cells.append(self.cell(units=n_hidden_neurons,
                                           dropout=self.dropout,
                                           kernel_regularizer=l2(self.l2),
                                           recurrent_regularizer=l2(self.l2)))

        self.encoder = RNN(encoder_cells, return_state=True, name='encoder') 
开发者ID:albertogaspar,项目名称:dts,代码行数:16,代码来源:Seq2Seq.py

示例6: evaluate

# 需要导入模块: from keras import metrics [as 别名]
# 或者: from keras.metrics import get [as 别名]
def evaluate(self, data, fn_inverse=None, horizon=1, fn_plot=None):
        """
        Evaluate model
        :return:
        """
        encoder_input_data, decoder_input_exog, y = data

        y_hat = self.predict(encoder_inputs=encoder_input_data,
                             pred_steps=horizon,
                             decoder_input_exog=decoder_input_exog)

        if fn_inverse is not None:
            y = fn_inverse(y)
            y_hat = fn_inverse(y_hat)

        y = np.float32(y)
        y_hat = np.float32(y_hat)

        if fn_plot is not None:
            fn_plot([y,y_hat])

        results = []
        for m in self.model.metrics:
            if isinstance(m, str):
                results.append(K.eval(K.mean(get(m)(y, y_hat))))
            else:
                results.append(K.eval(K.mean(m(y, y_hat))))
        return results 
开发者ID:albertogaspar,项目名称:dts,代码行数:30,代码来源:Seq2Seq.py

示例7: test_invalid_get

# 需要导入模块: from keras import metrics [as 别名]
# 或者: from keras.metrics import get [as 别名]
def test_invalid_get():

    with pytest.raises(ValueError):
        metrics.get(5) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:6,代码来源:metrics_test.py

示例8: evaluate_keras_metric

# 需要导入模块: from keras import metrics [as 别名]
# 或者: from keras.metrics import get [as 别名]
def evaluate_keras_metric(y_true, y_pred, metric):
    objective_function = metrics.get(metric)
    objective = objective_function(y_true, y_pred)
    return K.eval(objective) 
开发者ID:ECP-CANDLE,项目名称:Benchmarks,代码行数:6,代码来源:p1b3_baseline_keras2.py

示例9: on_epoch_end

# 需要导入模块: from keras import metrics [as 别名]
# 或者: from keras.metrics import get [as 别名]
def on_epoch_end(self, batch, logs={}):
        val_loss, val_acc, y_true, y_pred, y_true_class, y_pred_class = evaluate_model(self.model, self.val_gen, self.val_steps, self.metric, self.category_cutoffs)
        test_loss, test_acc, _, _, _, _ = evaluate_model(self.model, self.test_gen, self.test_steps, self.metric, self.category_cutoffs)
        self.progbar.append_extra_log_values([('val_acc', val_acc), ('test_loss', test_loss), ('test_acc', test_acc)])
        if float(logs.get('val_loss', 0)) < self.best_val_loss:
            plot_error(y_true, y_pred, batch, self.ext, self.pre)
        self.best_val_loss = min(float(logs.get('val_loss', 0)), self.best_val_loss)
        self.best_val_acc = max(float(logs.get('val_acc', 0)), self.best_val_acc) 
开发者ID:ECP-CANDLE,项目名称:Benchmarks,代码行数:10,代码来源:p1b3_baseline_keras2.py


注:本文中的keras.metrics.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。