首页 > 其他 > 详细

tensorflow2.0——多层全连接模板

时间:2020-08-15 18:26:18      阅读:136      评论:0      收藏:0      [点我收藏+]
import tensorflow as tf

x = tf.random.normal((2,3))                 #   模拟样本数据

model = tf.keras.Sequential([               #   定义全连接层结构
    tf.keras.layers.Dense(4,activation=relu),                 #   第一层输出为4
    tf.keras.layers.Dense(3,activation=relu),
    tf.keras.layers.Dense(2)                                    #   输出层不需要激活函数
])
out = model(x)                                                  #   前向预测值
print(out:,out)
print(model.summary())                                          #   网络结构打印
print()
for i in model.trainable_variables:                              #   打印训练参数
    print(i.name,i.shape)
   

技术分享图片

 

tensorflow2.0——多层全连接模板

原文:https://www.cnblogs.com/cxhzy/p/13509624.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!