使用 DNNRegressor 的损失函数是什么?

Edw*_*ald 3 python machine-learning neural-network deep-learning tensorflow

我正在使用DNNRegressor来训练我的模型。我在文档中搜索这个包装器使用的损失函数是什么,但我没有找到它。另一方面,有可能改变损失函数吗?。

谢谢你的建议。

lej*_*lot 5

它使用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)
Run Code Online (Sandbox Code Playgroud)

目前 API 不支持这里的任何更改。但是,由于它是开源的 - 您始终可以修改构造函数以在内部调用不同的函数,但损失不同。