quanteda / quanteda.classifiers

quanteda textmodel extensions for classifying documents
21 stars 2 forks source link

Problem with Quanteda Classifiers #31

Open pmacclay opened 1 year ago

pmacclay commented 1 year ago

I am having a problem when running a Convolutional Neural Network using Quanteda Classifiers. I try to replicate the analysis from the vignette, and I get the following result after running pred <- predict(tmod, newdata = newdata):

Error: AttributeError: 'Sequential' object has no attribute 'predict_classes' In addition: Warning message: In predict_classes(object$clefitted, x = data$matrix) : predict_classes() is deprecated and and was removed from tensorflow in version 2.6. Please update your code:

  • If your model does multi-class classification: (e.g. if it uses a softmax last-layer activation). model %>% predict(x) %>% k_argmax()

  • if your model does binary classification (e.g. if it uses a sigmoid last-layer activation). model %>% predict(x) %>% >(0.5) %>% k_cast("int32")

However, when I try to use model %>% predict(x) %>% k_argmax() or model %>% predict(x) %>% >(0.5) %>% k_cast("int32") I get the same result.

I know this is related to the version of TensorFlow, but I don't know how to fix it to get the code running.

yeokcmark commented 2 months ago

I have the same problem. Did you manage to find a way around it?