当前位置:网站首页>Tensorflow realize parameter adjustment of linear equations
Tensorflow realize parameter adjustment of linear equations
2022-08-09 10:46:00 【qq_26391203】
import tensorflow as tfimport numpy as np#create datax_data=np.random.rand(100).astype(np.float32)y_data=x_data*0.1+0.3 #target resultspan>#create tensorflow structure startWeights=tf.Variable(tf.random_uniform([1],-1.0,1.0))biases=tf.Variable(tf.zeros([1])) # The weights and biases are continuously learned from the initial value and approach the target valuey=Weights*x_data+biasesloss=tf.reduce_mean(tf.square(y-y_data))# mean square erroroptimizer=tf.train.GradientDescentOptimizer(0.5)train=optimizer.minimize(loss)init=tf.initialize_all_variables()# create tensorflow structure endsess=tf.Session()sess.run(init) #points to the processing placefor step in range(201):sess.run(train)if step%20==0:print(step,sess.run(Weights),sess.run(biases))Experiment results: 
The final experimental results shown above show that Weight is close to the target value of 0.1, and biases is close to the target value of 0.3
边栏推荐
猜你喜欢

LM小型可编程控制器软件(基于CoDeSys)笔记二十六:plc的数据存储区(模拟量输入通道部分)

OpenSSF的开源软件风险评估工具:Scorecards

人物 | 从程序员到架构师,我是如何快速成长的?

PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization Paper Reading

非科班毕业生,五面阿里:四轮技术面+HR一面已拿offer

activemq message persistence

2022年台湾省矢量数据(点线面)及数字高程数据下载

相伴成长,彼此成就 用友U9 cloud做好制造业数智化升级的同路人

真香!肝完Alibaba这份面试通关宝典,我成功拿下今年第15个Offer

Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
随机推荐
Dialogue with the DPO of a multinational consumer brand: How to start with data security compliance?See you on 8.11 Live!
pip常见命令和更改源文件
Received your first five-figure salary
想了解API接口,这一篇就够了
unix环境编程 第十五章 15.6 XSI IPC
unix系统编程 第十五章 15.2管道
编程技术提升
Pyhton实战汇总篇
商业技术解决方案与高阶技术专题 - 数据可视化专题
上传张最近做的E2用的xmms的界面的截图
Unix Environment Programming Chapter 15 15.9 Shared Storage
Since I use the HiFlow scene connector, I don't have to worry about becoming a "dropper" anymore
OpenGL 2.0编程例子
OpengGL绘制立方体的三种方法
对话跨国消费品牌DPO:数据安全合规从何做起?8.11直播见!
PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization论文阅读
xmms的均衡器试验成功 音效相当不错 比rockbox可能还要好
activemq 消息持久化
相伴成长,彼此成就 用友U9 cloud做好制造业数智化升级的同路人
Win7 远程桌面限制IP