多次检验的:
以learnign_rate为例子
learning_rate=[0.00001,0.0001,0.001,0.01,0.1,0.4];
loss_result=[]
accuracy_result=[]
for i in learning_rate:
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(256, kernel_initializer='random_uniform',bias_initializer='Zeros',activation='relu'),
tf.keras.layers.Dense(128, kernel_initializer='random_uniform',bias_initializer='Zeros',activation='relu'),
tf.keras.layers.Dense(10, kernel_initializer='random_uniform',bias_initializer='Zeros',activation='softmax')
])
adam=keras.optimizers.Adam(lr=i, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0.00, amsgrad=False)
model.compile(optimizer=adam,
loss='sparse_categorical_crossentropy',
metrics=['sparse_categorical_accuracy'])
model.summary()
history=model.fit(x_train, y_train, epochs=5,batch_size=32,validation_data=(x_test,y_test),validation_freq=2)
print(history)
loss_result.append(loss)
accuracy_result.append(