在Google Colab问题中训练MNIST数据集:

我正在专业版的Google colab笔记本中执行CNN。尽管x_train的形状为(60,000,28,28)。该模型仅在1875行上接受训练。有人遇到过这个问题吗?我的模型在本地计算机的jupyter笔记本上运行良好。它在所有60,000行上运行

    import tensorflow as tf
    enter code here`mnist = tf.keras.datasets.mnist'

    (x_train, y_train), (x_test, y_test) = mnist.load_data()
    x_train = x_train.astype('float32') / 255.0
    y_train = y_train.astype('float32') / 255.0

    print("x_train.shape:", x_train.shape)

    #Build the model
    from tensorflow.keras.layers import Dense, Flatten, Dropout
    model = tf.keras.models.Sequential([
            tf.keras.layers.Flatten(input_shape=(28,28)),
            tf.keras.layers.Dense(128, activation='relu'),
            tf.keras.layers.Dropout(0.2),
            tf.keras.layers.Dense(10, activation='softmax')
    ])

    r = model.fit(x_train, y_train, validation_data=(x_test,y_test), epochs = 10)


    Output:

    x_train.shape: (60000, 28, 28)

    Epoch 1/10
    1875/1875 [==============================] - 3s 2ms/step - loss: 2.2912e-06 - accuracy:                            0.0987 - val_loss: 7716.5078 - val_accuracy: 0.0980