我正在尝试使用 MNIST 数据集训练深度神经网络,这是我的 jupyter notebook 的一些代码:第一个块工作正常:# Select the hyperparameter batch sizeBATCH_SIZE = 100# Batch the train, validatiion and test datatrain_data = train_data.batch(BATCH_SIZE)validation_data = validation_data.batch(num_validation_samples)test_data = test_data.batch(num_test_samples)# Transform the validation data into tuples for the inputs and targetsvalidation_inputs, validation_targets = next(iter(validation_data))# Defining model hyperparametersinput_size = 784output_size = 10hidden_layer_size = 50# Defining the modelmodel = tf.keras.Sequential([ tf.keras.layers.Flatten(input_shape=(28, 28, 1)), tf.keras.layers.Dense(hidden_layer_size, activation='relu'), tf.keras.layers.Dense(hidden_layer_size, activation='relu'), tf.keras.layers.Dense(output_size, activation='softmax')])# Select the optimizer algorithm and the loss functionmodel.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
添加回答
举报
0/150
提交
取消