全连接网络
下面是一个4层的全连接网络
输入时28*28,打平后是784节点的手写数字图片
中间的隐藏层的节点数是256
输出层的节点是10
?...relu'),
layers.Dense(256, activation='relu'),
layers.Dense(256, activation='relu'),
layers.Dense(10...layers.Dense(120, activation='relu'), # 全连接层,120个节点
layers.Dense(84, activation='relu'),
layers.Dense(10...构建梯度计算环境
x = tf.expand_dims(x, axis=3) # 插入通道维度 ---> [b,28,28,1]
out = network(x) # 前向计算,获得10...类别的概率分布, [b,784] ---> [b,10]
y_onehot = tf.one_hot(y, depth=10)
loss = criteon(y_onehot, out) #