当我为我的CNN模型使用fit_generate方法时出现此错误 - “无法导入PIL.Image。使用`array_to_img`需要PIL。”

时间:2018-03-13 14:14:38

标签: python tensorflow machine-learning deep-learning keras

from keras.models import Sequential
from keras.preprocessing.image import ImageDataGenerator
from keras.layers import Conv2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
import tensorflow as tf
  

编译

classifier.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy'])
  

当我跑到下面的线时出现错误

**classifier.fit_generator(training_set,
steps_per_epoch = 8000,
epochs = 25,
validation_data = test_set,
validation_steps = 2000)**

A snapshot of the error

1 个答案:

答案 0 :(得分:0)

(供别人参考) 找到解决方案: 卸载Anaconda并重新安装Anaconda3 = 1.6.2。然后使用anaconda-prompt命令安装Theano + TensorFlow和Keras。