当前位置:网站首页>Tensorflow模型整体构建流程
Tensorflow模型整体构建流程
2022-08-09 21:35:00 【phac123】
TF构造八股文
- Import: 导入相关的包
- train and test: 处理好训练与测试数据集,包括乱序等操作
- models.Sequential: 搭建网络模型
- model.compile: 设置优化算法,配置训练方法
- model.fit: 设置训练时的学习率,迭代次数,batch_size,对模型进行训练;
- model.summary:打印出网络结构和参数统计
简单实现
# 1. import
import tensorflow as tf
# 2. train and test
w = tf.Variable(tf.constant(5, dtype=tf.float32))
# 3. model.sequential
# 4. model.compile and 5. model.fit
lr = 0.2
epochs = 40
for epoch in range(epochs):
with tf.GradientTape() as tape:
loss = tf.square(w + 1) # 定义loss函数
grads = tape.gradient(loss, w) # 求loss对w的梯度
w.assign_sub(lr * grads)
print("After %s epoch, w is %f, loss is %f" % (epoch, w.numpy(), loss)) # 6. model.summary()
边栏推荐
- 【Efficient Tools】Remote Control Software ToDesk (Favorites)
- 如何让您的公司内容满足 GDPR 合规性
- MySQL跨表、多表更新SQL语句总结
- mysql配置参数详解[通俗易懂]
- XXE-XML外部实体注入-知识点
- Beat the interviewer, the CURD system can also make technical content
- CMake installation upgrade higher version
- 普源精电上半年扭亏为盈,高端产品持续发力!你看好仪器界“华为”吗?
- 题解:Edu Codeforces 109(div2)
- 蓝牙模块有哪些种类?BLE低功耗蓝牙模块有什么特点?
猜你喜欢

windos安装Mysql8.0,及解决重新登录异常问题 ERROR 1045 (28000)

Optimization of SQL Statements and Indexes

小黑leetcode清爽雨天之旅,刚吃完宇飞牛肉面、麻辣烫和啤酒:112. 路径总和

cad图纸怎么复制到word文档里面?Word里插CAD图怎么弄?

DSPE-PEG-Silane, DSPE-PEG-SIL, phospholipid-polyethylene glycol-silane modified silica particles

Don't use array.length-1 to get the last item of the array

人人都可以DIY的大玩具,宏光MINIEV GAMEBOY产品力强,出行新装备

定投的基金

Excel如何打出正负号?Excel打出正负号的方法

Unity2D_背景粒子效果
随机推荐
hdu 1503 Advanced Fruits(最长公共子序列的应用)
DSPE-PEG-Silane, DSPE-PEG-SIL, phospholipid-polyethylene glycol-silane modified silica particles
微软Excel表格点击单元格行和列都显示颜色怎么弄?聚光灯效果设置
fixed investment fund
C语言中的文件是什么?
SecureCRT强制卸载
RHEL7系统修复rm -rf /boot /etc/fstab
2021(ICPC)亚洲区域赛昆明站(CGHIJLM)
Unity2D_背景粒子效果
LoRa Basics无线通信技术和应用案例详解
韩国网络安全体系特征与发展前景
上海控安SmartRocket系列产品推介(三):SmartRocket iVerifier计算机联锁系统验证工具
gmail+mtalk配合打免费网络电话。
Application of Acrel5000web Energy Consumption System in a College-Susie Week
数据集成API如何成为企业数字化转型的关键?
6 g underwater channel modeling were summarized based on optical communication
Overview of Security Analysis Technology for Smart Home Devices
Next second data: the transformation of the modern data stack brought about by the integration of lake and warehouse has begun
Excel如何打出正负号?Excel打出正负号的方法
企业数据打通有什么好处?不同行业怎么解决数据打通难题?