tensorflow-mnist构建网络主要函数

#1、用堆叠方式搭建网络
tf.keras.models.Sequential
#2、扁平化输入图片,input_shape为输入图片的规格
tf.keras.layers.Flatten(input_shape=(*, *))
#3、设置中间层的神经元个数、激活函数、偏置....
tf.keras.layers.Dense(神经元个数,  激活函数......)
#4、为防止过拟合的Dropout方法,drop掉这么多比例的输入
tf.keras.layers.Dropout(rate)
#5、为训练设置模型参数
model.compile(optimizer,loss, metrics)
#6、输入训练样本及标签,及迭代次数设置,达到epochs值就停止迭代
model.fit(x_train, y_train, epochs)
#7、评估,返回模型在测试集上的损失值和评估值,verbose取1,控制台会有训练流水产生,取0就什么都没有
model.evaluate(x_test,  y_test, verbose)

Dense函数参数
Dropout参数介绍

猜你喜欢

转载自blog.csdn.net/firesunn/article/details/106337982