繁体   English   中英

class_id 使用 metric_recall_at_precision 或 metric_precision_at_recall 支持 R (keras / tensorflow) 中的分类深度学习问题

[英]class_id support for categorical deep learning problems in R (keras / tensorflow) using metric_recall_at_precision or metric_precision_at_recall

Using R 3.6.3, keras 2.9.0 and tensorflow 2.9.0 on a Windows 10 machine with GPU support (reticulate points to python 3.6.10)
我无法使用度量metric_recall_at_precisionmetric_precision_at_recall的可选class_id参数编译 model(3 个分类类)。 产生以下错误:

py_call_impl (callable, dots$args, dots$keywords) 中的错误:TypeError: init () got an unexpected keyword argument 'class_id'

The keras documentation for these metrics clearly states that "class_id" is an optional argument... The model compiles correctly using metric_sparse_categorical_accuracy or if I convert the model to binary classification (sigmoid output) and use metric_recall_at_precision or metric_precision_at_recall

这是生成错误的(简化)model 的代码:

model <- keras_model_sequential() %>% 
     layer_conv_1d(filters = 64, kernel_size = 11, strides = 5, activation = "relu", input_shape = c(446,3)) %>% 
     layer_max_pooling_1d(pool_size = 5) 

model %>% 
    layer_dropout(rate = 0.1) %>%
    layer_flatten() %>% 
    layer_dense(units = 64, activation = "relu") %>%
    layer_dense(units = 3, activation = "softmax")  

model %>% compile(
    optimizer = "adam",
    loss = "sparse_categorical_crossentropy",   
    metrics =  metric_recall_at_precision(precision=precision, class_id=0))

知道如何使用 class_id 参数编译这个 model 吗?

在我的python虚拟环境中升级Tensorflow版本解决了问题! 我升级到Tensorflow v2.6.0现在可以编译我的模型了!

感谢t-kalinowskiQuinten的指点!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM