当前位置:网站首页>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
边栏推荐
- stimulus.js 初体验
- Shell script combat (2nd edition) / People's Posts and Telecommunications Press Script 1 Find programs in the PATH
- activemq message persistence
- 关于页面初始化
- String类型的字符串对象转实体类和String类型的Array转List
- BERT预训练模型(Bidirectional Encoder Representations from Transformers)-原理详解
- 编程技术提升
- activemq 消息持久化
- cnn的输入输出
- 按键精灵之输出文本
猜你喜欢
随机推荐
The complete grammar of CSDN's markdown editor
一键完成物联网产品注册,快速体验在线调试设备
Received your first five-figure salary
activemq message persistence
Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
可能95%的人还在犯的PyTorch错误
Shell script combat (2nd edition) / People's Posts and Telecommunications Press Script 2 Validate input: letters and numbers only
Solve the ali cloud oss - the original 】 【 exe double-click response can't open, to provide a solution
MNIST机器学习入门
CSDN的markdown编辑器语法完整大全
深度学习--自编码器(AutoEncoder)
OpenGL ES2.0编程三部曲(转载自MyArrow)
For versions corresponding to tensorflow and numpy, report FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecate
在webgis中显示矢量化后的风险防控信息
1001 害死人不偿命的(3n+1)猜想 (15 分)
非科班毕业生,五面阿里:四轮技术面+HR一面已拿offer
中断系统结构及中断控制
自从我使用HiFlow场景连接器后,在也不用担心成为“落汤鸡”了
研发需求的验收标准应该怎么写? | 敏捷实践
强化学习 (Reinforcement Learning)