TensorFlow.Keras.Model class 详解

Class: tf.keras.Model

tf.keras.Model(
    *args, 
    **kwargs
)

*args:

  • inputs: The input(s) of the model: a keras.Input object or list of keras.Input objects.
  • outputs: The output(s) of the model. See Functional API example below.
  • name: String, the name of the model.

Methods

Model.compile()

Configures the model for training.

设置training参数

compile(
    optimizer='rmsprop',        # [str] define optimizer
    loss=None,                  # [str] define loss type
    metrics=None,               # [list or dict] define evaluation metrics, typically is 'accuracy'
    loss_weights=None,          # [list or dict] define the weights of different losses
    weighted_metrics=None,      # weights of evaluation metrics
    run_eagerly=None,           # [Bool] 
    steps_per_execution=None,   # [int] The number of batches to run during each tf.function call. ?
    jit_compile=None,           # ?
    **kwargs
)

Model.compute_loss()

Compute the total loss, validate it, and return it.

计算loss值

compute_loss(
    x=None,                 # input data
    y=None,                 # target data (label)
    y_pred=None,            # predictions returned by the model
    sample_weight=None      # sample_weight
)

Model.compute_metrics()

Update metric states and collect all metrics to be returned.

更新一次metrics,并返回所有metrics的值 (metrics?)

compute_metrics(
    x, y, y_pred, sample_weight
)

Model.evaluate()

Returns the loss value & metrics values for the model in test mode.

返回loss值和model中metrics的值

evaluate(
    x=None,                     # [npy_array, tensor, dict, tf.data] input
    y=None,                     # [npy_array, tensor, dict, tf.data] target data
    batch_size=None,            # [int] Number of samples per batch of computation [32]
    verbose='auto',             # [0,1,2] 0 = silent, 1 = progress bar, 2 = single line. 进度条
    sample_weight=None,         
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值