keras API的使用,神经网络层,优化器,损失函数,查看模型层数,compile和fit训练
2024-09-28 10:44:52
layers介绍
Flatten和Dense介绍
优化器
损失函数
compile用法
第二个是onehot编码
模型训练 model.fit
两种创建模型的方法
from tensorflow.python.keras.preprocessing.image import load_img,img_to_array
from tensorflow.python.keras.models import Sequential,Model
from tensorflow.python.keras.layers import Dense,Flatten,Input
import tensorflow as tf
from tensorflow.python.keras.losses import sparse_categorical_crossentropy def main(): #通过Sequential创建网络
model = Sequential(
[
Flatten(input_shape=(28,28)),
Dense(64,activation=tf.nn.relu),
Dense(128,activation=tf.nn.relu),
Dense(10,activation=tf.nn.softmax)
]
)
print(model) #通过Model创建模型
data = Input(shape=(784,))
out = Dense(64)(data)
model_sec = Model(inputs=data,outputs=out)
print(model_sec)
print(model.layers,model_sec.layers)
print(model.input,model.output)
print(model.summary())
print(model_sec.summary()) if __name__ == '__main__':
main()
最新文章
- UESTC 1227 &; POJ 3667 Hotel
- sql for xml 嵌套
- 360网站卫士推出google字体加速方案
- Moloch
- Apache 多站点(虚拟主机)
- 基于HCE移动支付研究报告
- Android设置全屏
- 编译 &; 预处理
- 要重定向 IO 流,Process 对象必须将 UseShellExecute 属性设置为 False。
- Exynos4412交叉编译环境搭建
- 个人jQuery的使用总结
- python学习日记(常用模块)
- c++实验二
- JSTL和EL的使用
- HttpWebRequest简单使用
- .NET Core 2.1中的HttpClientFactory最佳实践
- (转)The C10K problem翻译
- Android UI开发神兵利器之Android Action Bar Style Generator
- C# 如何获取鼠标在屏幕上的位置,不论程序是否为活动状态
- [CQOI2009]叶子的染色
热门文章
- web样式css
- coding++:mybatis update foreach (SQL循环)批量更新
- Prism 源码解读5-数据绑定和命令
- ThreadAbortException是可以传递的
- __str_方法和__repr__的区别
- [洛谷1437&;Codevs1257]敲砖块<;恶心的dp>;
- 创建Windows10无人值守(自动应答文件)教程
- Day20-tomcat
- Django之queryset API
- 如何做监控?Google SRE 解密