我正在为癌症检测Kaggle挑战建立一个图像分类器。这是我正在使用的代码。在
`train_datagen = ImageDataGenerator(rescale=1./255,
validation_split=0.15
)
test_datagen = ImageDataGenerator(rescale=1./255)
train_path = MAIN_DIR + '/CancerTrain'
valid_path = MAIN_DIR + '/CancerTrain'
train_generator = train_datagen.flow_from_dataframe(
dataframe = train_labels,
directory=train_path,
x_col = 'id',
y_col = 'label',
has_ext=False,
subset='training',
target_size=(96, 96),
batch_size=64,
class_mode='binary'
)
validation_generator = train_datagen.flow_from_dataframe(
dataframe=df,
directory=valid_path,
x_col = 'id',
y_col = 'label',
has_ext=False,
subset='validation', # This is the trick to properly separate train and validation dataset
target_size=(96, 96),
batch_size=64,
shuffle=False,
class_mode='binary'
)`
但是,每当我运行它时,都会出现以下错误:
^{pr2}$我到处找遍了,似乎找不到解决办法。这个方法现在叫什么不同了吗?在
我在使用keras2.1.4时也遇到了同样的错误。我只是用
pip install keras upgrade
升级。Keras 2.2.4没有给出相同的错误。现在一切都好了。在如果您想使用
flow_from_dataframe()
方法,我建议您执行以下操作:卸载当前keras预处理模块:
从以下git链接安装keras预处理模块:
^{2}$(您可以看到方法是可用的in the source code here)
然后导入
ImageDataGenerator
,如下所示:相关问题 更多 >
编程相关推荐