我正在使用 DNNRegressor 来训练我的模型。我在文档中搜索这个包装器使用的损失函数但我找不到它。另一方面,可以改变那种损失函数吗?。
感谢您的建议。
答案 0 :(得分:3)
它使用target_column.py中定义的L2损失(均方误差):
def regression_target(label_name=None,
weight_column_name=None,
target_dimension=1):
"""Creates a _TargetColumn for linear regression.
Args:
label_name: String, name of the key in label dict. Can be null if label
is a tensor (single headed models).
weight_column_name: A string defining feature column name representing
weights. It is used to down weight or boost examples during training. It
will be multiplied by the loss of the example.
target_dimension: dimension of the target for multilabels.
Returns:
An instance of _TargetColumn
"""
return _RegressionTargetColumn(loss_fn=_mean_squared_loss,
label_name=label_name,
weight_column_name=weight_column_name,
target_dimension=target_dimension)
目前API不支持此处的任何更改。但是,由于它是开源的 - 你总是可以修改构造函数以在内部调用不同的函数,但会有不同的损失。