[在 Jupyter Lab 环境上运行] 在张量流上训练 CNN 时:
history = model.fit(
train_generator,
steps_per_epoch=3,
epochs=5,
verbose = 1,
Run Code Online (Sandbox Code Playgroud)
'OOM when allocating tensor with shape'
当我运行我的算法时,我得到了一个。
据我了解,这意味着我没有耗尽足够的 GPU 内存。如何连接 Jupyter 上的服务器以访问更多内存来运行我的训练神经网络?
我使用以下包和代码来加载图像:
from tensorflow.keras.preprocessing.image import ImageDataGenerator
# Conduct pre-processing on the data to read and feed the images from the directories into the CNN
# Re-scale data as pixels have value of 0-255
train_datagen = ImageDataGenerator(rescale=1/255)
validation_datagen = ImageDataGenerator(rescale=1/255)
# Feed training dataset images in via batches of 250
train_generator = train_datagen.flow_from_directory ( …
Run Code Online (Sandbox Code Playgroud)