Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 加权海关损失_Python_Tensorflow_Machine Learning_Keras_Loss Function - Fatal编程技术网

Python 加权海关损失

Python 加权海关损失,python,tensorflow,machine-learning,keras,loss-function,Python,Tensorflow,Machine Learning,Keras,Loss Function,您可以像这样在kera中使用加权MSE model.fit(sample_weight=weights, loss='mse', ...) 我想使用加权RMSE,但Keras库没有RMSE,我自己写的 def root_mean_squared_error(y_true, y_pred): return K.sqrt(K.mean(K.square(y_pred - y_true))) 但是如何使用权重呢?从中,似乎是自动完成的: 创建自定义损失: 任何带有签名loss_fn(y_t

您可以像这样在kera中使用加权MSE

model.fit(sample_weight=weights, loss='mse', ...)
我想使用加权RMSE,但Keras库没有RMSE,我自己写的

def root_mean_squared_error(y_true, y_pred):
    return K.sqrt(K.mean(K.square(y_pred - y_true)))
但是如何使用权重呢?

从中,似乎是自动完成的:

创建自定义损失: 任何带有签名loss_fn(y_true,y_pred)的可调用函数,返回一个损失数组(输入批处理中的一个样本),都可以作为损失传递给compile()请注意,任何此类损失都会自动支持样本加权。