用法:
class mxnet.metric.CrossEntropy(eps=1e-12, name='cross-entropy', output_names=None, label_names=None)
- eps:(
float
) - 對於預測值為 0 或 1 的交叉熵損失未定義,因此預測值與小常數相加。 - name:(
str
) - 此度量實例的名稱用於顯示。 - output_names:(
list of str
, or
None
) - 使用update_dict 更新時應使用的預測名稱。默認情況下包括所有預測。 - label_names:(
list of str
, or
None
) - 使用update_dict 更新時應使用的標簽名稱。默認情況下包括所有標簽。
- eps:(
參數:
計算交叉熵損失。
一批樣本大小 的交叉熵由下式給出
其中 當且僅當樣本 屬於類 。 表示樣本 屬於類 的概率。
例子:
>>> predicts = [mx.nd.array([[0.3, 0.7], [0, 1.], [0.4, 0.6]])] >>> labels = [mx.nd.array([0, 1, 1])] >>> ce = mx.metric.CrossEntropy() >>> ce.update(labels, predicts) >>> print ce.get() ('cross-entropy', 0.57159948348999023)
相關用法
- Python mxnet.metric.CompositeEvalMetric用法及代碼示例
- Python mxnet.metric.CustomMetric用法及代碼示例
- Python mxnet.metric.F1用法及代碼示例
- Python mxnet.metric.TopKAccuracy用法及代碼示例
- Python mxnet.metric.create用法及代碼示例
- Python mxnet.metric.RMSE用法及代碼示例
- Python mxnet.metric.MAE用法及代碼示例
- Python mxnet.metric.MCC用法及代碼示例
- Python mxnet.metric.MSE用法及代碼示例
- Python mxnet.metric.np用法及代碼示例
- Python mxnet.metric.Accuracy用法及代碼示例
- Python mxnet.metric.PCC用法及代碼示例
- Python mxnet.metric.Perplexity用法及代碼示例
- Python mxnet.metric.PearsonCorrelation用法及代碼示例
- Python mxnet.metric.NegativeLogLikelihood用法及代碼示例
- Python mxnet.module.BaseModule.get_outputs用法及代碼示例
- Python mxnet.module.BaseModule.forward用法及代碼示例
- Python mxnet.module.BaseModule.bind用法及代碼示例
- Python mxnet.module.BaseModule.init_params用法及代碼示例
- Python mxnet.module.BaseModule.get_params用法及代碼示例
- Python mxnet.module.BaseModule.set_params用法及代碼示例
- Python mxnet.module.BaseModule.update用法及代碼示例
- Python mxnet.module.SequentialModule.add用法及代碼示例
- Python mxnet.module.BaseModule.iter_predict用法及代碼示例
- Python mxnet.module.BaseModule.save_params用法及代碼示例
注:本文由純淨天空篩選整理自apache.org大神的英文原創作品 mxnet.metric.CrossEntropy。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。