Skip to content

tensorflow function predict_classes() removed in 2.6 #16

@Astrocito98

Description

@Astrocito98

Hi, thanks for putting this up, im using this code for my MD project. Everything working well until the moment where i try to create a behavior classifier. Seems like the function predict_classes() has been removed from tensorflow in v2.6. When trying to call the function ClassifyBehaviors it shows the error

AttributeError: 'Sequential' object has no attribute 'predict_classes'

and points what code to use instead. When I try to correct the code on my own the function looks like this

ClassifyBehaviors <- function(t,model, model_parameters){
if(!IsTrackingData(t)){
stop("Object is not of type TrackingData")
}
t <- CreateTestSet(t, model_parameters$integration_period)
t$labels$classifications <- model %>% predict(t$train_x) %>% k_argmax()``
###before "t$labels$classifications <- model %>% predict_classes(t$train_x)###
t$labels$classifications <- c(rep(NA,model_parameters$integration_period), model_parameters$Feature_names[t$labels$classifications + 1], rep(NA,model_parameters$integration_period))
return(t)
}

That way it allows it to pass that last error, but then it shows

Error in model_parameters$Feature_names[t$labels$classifications + 1] :
invalid subscript type 'environment'
``

I'm stuck in trying to correct this error, hope you can update the code so it works with TF v2.6+

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions