小编Tob*_*nst的帖子

ValueError:使用数据集作为输入时不支持“sample_weight”参数

我想训练 keras 模型并使用样本权重。我的数据源是 tf.data.dataset 类型。sample_weight使用函数参数时出现以下错误model.fit

ValueError: `sample_weight` argument is not supported when using dataset as input.
Run Code Online (Sandbox Code Playgroud)

代码如下:

model.fit(tf_train_dataset,
          epochs=epochs,
          verbose=self.verbose,
          batch_size=batch_size,
          callbacks=callbacks,
          sample_weight=sample_weights
          steps_per_epoch=self.steps_per_epoch,
          use_multiprocessing=True,
Run Code Online (Sandbox Code Playgroud)

tf_train_dataset是由 创建的tf.data.Dataset.from_generator。我如何传递每个样本的权重并将其应用于损失和最终训练?

python machine-learning keras tensorflow

1
推荐指数
1
解决办法
1823
查看次数

标签 统计

keras ×1

machine-learning ×1

python ×1

tensorflow ×1