google colab 中的运行时自动重启错误

runtime automatic restart error in google colab

嗨,我想使用 google colab 为我的分类训练模型,但是当我在几秒钟后开始训练时,它显示 'Runtime died. Automatically restarting.'

我的模型是:

model=keras.Sequential([
    keras.layers.Flatten(input_shape=(230, 320, 3)),
    keras.layers.Dense(32,activation=tf.nn.relu),
    keras.layers.Dense(10,activation=tf.nn.relu),
    keras.layers.Dense(5,activation=tf.nn.softmax),
])
opt=tf.train.AdamOptimizer()
model.compile(loss='sparse_categorical_crossentropy',optimizer=opt,metrics=['accuracy'])

训练代码为:

model.fit(train_data,train_labels,epochs=25,validation_split=0.2)

有什么建议吗?

所以我解决了这个问题,错误是因为我选择了一个图像通道,当我选择了 3 个通道时,问题就消失了。