【发布时间】:2019-04-08 15:56:56
【问题描述】:
我尝试为其分配权重的数据集略有不平衡。
How to set class_weight in keras package of R? 中提供的示例不适用于我。当我尝试相同时,使用我的代码:
system.time (
baseline_history <- fit (
object = model_baseline,
x = as.matrix(x_train_tbl),
y = y_train_vec,
batch_size = 1024,
epochs = 30,
class_weight = list("0" = 1, "1" = 1.67),
validation_split = 0.2) )
我收到以下错误:
Error in py_call_impl(callable, dots$args, dots$keywords) :
ValueError: `class_weight` must contain all classes in the data. The classes {'0', '1'} exist in the data but not in `class_weight`.
我有点不知所措,因为我在 class_weights 中明确声明它是一个列表。我什至尝试过
weights <- list("0" = 1, "1" = 1.67)
> weights
$`0`
[1] 1
$`1`
[1] 1.67
is.list(weights)
[1] TRUE
为了确保它有效,但我仍然遇到同样的错误。有什么想法吗?
【问题讨论】:
标签: r class keras deep-learning