-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module 'keras.utils' has no attribute 'to_categorical' #1
Comments
keras版本不同的原因,我在调试的时候也遇到这个问题,看不同版本的api解决把,是个坑... |
我用的 |
107行附近,修改为:
72行附近,修改为:
然后建立一个名字是 |
Hi, I am getting the same issue, I was using cifar code from the location - Error I get is - module 'keras.utils' has no attribute 'to_categorical'. Let me know if anyone was able to resolve this. |
@skoundin I have no problem running it. What version of Keras and TF are you on? Mind sharing your environment text? |
model.fit(x_train, y_train, batch_size=batch_size, epochs=n_epoch,verbose=1) ^ SyntaxError: invalid syntax |
|
我试过了按照这种方法确实能用,感谢! |
I tried the solution @Edward-Joker posted and it didn't work for me. I'm running Tensorflow version 2.5.0. By trial and error I found that Hope it helps someone! |
TF version- 2.5.0 Resolving this issue, first import to_categorical()
then write like
It will work. |
it is ok |
keras version -2.6.0
|
I am not sure if this was solved, however, I encountered the same error and this solved it for me. First import Then copy the below code and you should be fine y_train = keras.utils.np_utils.to_categorical(y_train,num_classes=3) |
from keras import utils as np_utils
y_train = np_utils.to_categorical(y_train,num_classes=3)
y_test = np_utils.to_categorical(y_test,num_classes=3)
为什么会出现这个错误?
The text was updated successfully, but these errors were encountered: