DNN算法
多层感知机MLP
DNN算法2、一个例程代码
class MLP(tf.keras.Model):
def __init__(self):
super().__init__()
self.flatten = tf.keras.layers.Flatten() # Flatten层将除第一维(batch_size)以外的维度展平
self.dense1 = tf.keras.layers.Dense(units=100, activation=tf.nn.relu)
self.dense2 = tf.keras.layers.Dense(units=10)
def call(self, inputs): # [batch_size, 28, 28, 1]
x = self.flatten(inputs) # [batch_size, 784]
x = self.dense1(x) # [batch_size, 100]
x = self.dense2(x) # [batch_size, 10]
output = tf.nn.softmax(x)
return output
参考资料:
1、深度神经网络(DNN)
https://zhuanlan.zhihu.com/p/29815081
2、基础示例:多层感知机(MLP)
https://www.bookstack.cn/read/TensorFlow2.0/spilt.2.c868281a01ad8ec0.md
网友评论