keras.model.compile()函数参数用法介绍

废话不多说,happyModel是一个快乐挑战模型,吴恩达深度学习第四课第二周keras作业里的compile函数。

// An highlighted block
happyModel.compile(
    optimizer,
    loss,
    metrics=None,
    loss_weights=None,
    sample_weight_mode=None,
    weighted_metrics=None,
    target_tensors=None,
    **kwargs,
)
// An highlighted block
Arguments
    optimizer: String (name of optimizer) or optimizer object.
        See [optimizers](/optimizers).
    loss: String (name of objective function) or objective function.
        See [losses](/losses).
        If the model has multiple outputs, you can use a different loss
        on each output by passing a dictionary or a list of losses.
        The loss value that will be minimized by the model
        will then be the sum of all individual losses.
    metrics: List of metrics to be evaluated by the model
        during training and testing.
        Typically you will use `metrics=['accuracy']`.
        To specify different metrics for different outputs of a
        multi-output model, you could also pass a dictionary,
        such as `metrics={'output_a': 'accuracy'}`.
    loss_weights: Optional list or dictionary specifying scalar
        coefficients (Python floats) to weight the loss contributions
        of different model outputs.
        The loss value that will be minimized by the model
        will then be the *weighted sum* of all individual losses,
        weighted by the `loss_weights` coefficients.
        If a list, it is expected to have a 1:1 mapping
        to the model's outputs. If a tensor, it is expected to map
        output names (strings) to scalar coefficients.
    sample_weight_mode: If you need to do timestep-wise
        sample weighting (2D weights), set this to `"temporal"`.
        `None` defaults to sample-wise weights (1D).
        If the model has multiple outputs, you can use a different
        `sample_weight_mode` on each output by passing a
        dictionary or a list of modes.
    target_tensors: By default, Keras will create placeholders for the
        model's target, which will be fed with the target data during
        training. If instead you would like to use your own
        target tensors (in turn, Keras will not expect external
        Numpy data for these targets at training time), you
        can specify them via the `target_tensors` argument. It can be
        a single tensor (for a single-output model), a list of tensors,
        or a dict mapping output names to target tensors.
    weighted_metrics: List of metrics to be evaluated and weighted
        by sample_weight or class_weight during training and testing
    **kwargs: When using the Theano/CNTK backends, these arguments
        are passed into K.function. When using the TensorFlow backend,
        these arguments are passed into `tf.Session.run`.

# Raises
    ValueError: In case of invalid arguments for
        `optimizer`, `loss`, `metrics` or `sample_weight_mode`.
// An highlighted block
论据

optimizer:字符串(优化器的名称)或优化器对象。

loss:字符串(目标函数的名称)或目标函数。
如果模型有多个输出,则可以使用不同的损耗通过传递一个字典或一个损失列表。模型将最小化的损失值将是所有个人损失的总和。

metrics:模型要评估的指标列表在培训和测试期间。
通常,您将使用`metrics=['accuracy']`。为多输出模型,你也可以传递一个字典,例如`metrics={'output_a':'accuracy'}`。

loss_weights:指定标量的可选列表或字典系数(Python浮动),用于对损失贡献进行加权不同的模型输出。模型将最小化的损失值然后将是所有单个损失的*加权和*,由“loss_weights”系数加权。如果是列表,则应具有1:1映射模型的输出。如果是张量,则应映射输出名称(字符串)到标量系数。

sample_weight_mode:如果需要按时间分步执行采样权重(2D权重),将其设置为“临时”。
`“无”默认为采样权重(1D)。
如果模型有多个输出,则可以使用不同的
`通过传递字典或模式列表。

target_tensors:默认情况下,Keras将为模型的目标,在训练如果你想用你自己的目标张量(反过来,Keras不会期望外部训练时这些目标的数字)可以通过“targettensors”参数指定它们。它可以是单个张量(对于单个输出模型)、张量列表,或将输出名称映射到目标张量的dict。

weighted_metrics:要评估和加权的度量列表在训练和测试期间按样本重量或类别重量

**kwargs:当使用Theano/CNTK后端时,这些参数传递到K.函数中。当使用TensorFlow后端时,这些参数被传递到“tf.Session.run”中。

#Raises
ValueError:如果的参数无效
`优化器``loss``metrics``sample_weight_mode`

整理不易,如有雷同的请帮忙举报。转载需注明原文链接。谢谢观看!

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值