相关疑难解决方法(0)

Google Colab 无法访问云端硬盘内容

即使我将我的 Google Drive(及其中的数据集)定义为 google colab,但是当我运行我的代码时,我给出了这个错误:FileNotFoundError: [Errno 2] No such file or directory: 'content/drive/My Drive/.. ..

我已经在 google colab 中定义了 google drive,我可以通过 google colab 访问它,但是当我运行我的代码时,我给出了这个错误

from keras.models import Sequential
from keras.layers import Convolution2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
model=Sequential()
model.add(Convolution2D(32,3,3,input_shape=(64,64,3),activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Convolution2D(32,3,3,activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Flatten())
model.add(Dense(output_dim=128,activation='relu'))
model.add(Dense(output_dim=1,activation='sigmoid'))
model.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])

from keras.preprocessing.image import ImageDataGenerator
train_datagen=ImageDataGenerator(
    rescale=1./255,
    shear_range=0.2,
    zoom_range=0.2,
    horizontal_flip=True)
test_datagen=ImageDataGenerator(rescale=1./255)

training_set=train_datagen.flow_from_directory(
    directory='content/drive/My Drive/Convolutional_Neural_Networks/dataset/training_set',
    target_size=(64,64),
    batch_size=32,
    class_mode='binary')
test_set=test_datagen.flow_from_directory(
    directory='content/drive/My Drive/Convolutional_Neural_Networks/dataset/test_set',
    target_size=(64,64),
    batch_size=32,
    class_mode='binary')

#train
model.fit_generator(
    training_set,
    samples_per_epoch=8000,
    nb_epoch=2, …
Run Code Online (Sandbox Code Playgroud)

deep-learning conv-neural-network keras google-colaboratory

1
推荐指数
2
解决办法
4万
查看次数