Keras flow_from_directory function returning error: [WinError 3] The system cannot find the path specified

Keras flow_from_directory function returning error: [WinError 3] The system cannot find the path specified

我在 Python 中的 Keras 代码如下所示:

training_set = train_datagen.flow_from_directory('dataset/training_set',
                                                target_size=(64, 64),
                                                batch_size=32,
                                                class_mode='binary')

我不断收到此错误:

[WinError 3] The system cannot find the path specified: 'dataset/training_set'

我已经从各个方面确认这条路径是正确的,但它仍然会抛出错误。请帮忙。

我发现我出现上述错误的原因是因为我的路径很长

您只能在错误中看到 'dataset/training_set',但总的来说 python 当然是选择整个路径。碰巧我的路很长。

我没有收到有关路径长度的错误,而是收到找不到路径的错误。

我只是通过更改一些文件夹名称来更改路径的长度并且成功了。

希望它能对外面的人有所帮助。