question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No method "predict_classes" in Model

See original GitHub issue

It seems that only Sequential models have the predict_classes method, which means that a model built using the functional API cannot be wrapped using the SKlearn KerasClassifier class. Is there a technical reason this is not implemented?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
ghostcommented, Apr 20, 2017

Here is an example for nlp `

labels = list(set(y))
nb_classes = len(labels) + 1
label2ind = {label: index+1 for index, label in enumerate(labels)}
ind2label = {(index+1): label for index, label in enumerate(labels)}

def encode(y):
    return np.asarray([to_categorical([label2ind[word] for word in sentence], nb_classes) for  sentence in y])

def decode(y):
    y_ind = np.argmax(y, axis=-1)
    return [[ind2label[word] for word in sentence] for sentence in y_ind]`
0reactions
spedygiorgiocommented, Jul 10, 2019

It would be nice to add this method to the Model class, in order to give the same funtionalities of the Sequential api

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'Model' object has no attribute 'predict_classes'
The predict_classes method is only available for the Sequential class (which is the class of your first model) but not for the Model...
Read more >
'Sequential' object has no attribute 'predict_classes ... - GitHub
model.predict_classes is deprecated, So you can try replacing ... predict_x=model.predict(token_list) ... why it is not working for me?
Read more >
'Sequential' object has no attribute 'predict_classes'
Hello All,. I'm trying to run my model but facing "'Sequential' object has no attribute 'predict_classes' " I have
Read more >
How to use a model to do predictions with Keras - ActiveState
Keras models can be used to detect trends and make predictions, using the model.predict() class and it's variant, ...
Read more >
'Functional' object has no attribute 'predict_classes'' - Data ...
I was able to fix my issue by making the following changes. From: # Making prediction y_pred = (model.predict_classes(testX)) y_true ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found