一个TensorFlow例子
2024-09-04 17:28:28
一个TensorFlow的例子
import tensorflow as tf
x = tf.constant(1.0, name='input')
w = tf.Variable(0.8, name='weight')
y = tf.multiply(w, x, name='output')
y_ = tf.constant(0.0, name='correct_value')
loss = tf.pow(y - y_, 2, name='loss')
train_step = tf.train.GradientDescentOptimizer(0.025).minimize(loss)
for value in [x, w, y, y_, loss]:
tf.summary.scalar(value.op.name, value)
summaries = tf.summary.merge_all()
with tf.Session() as sess:
summary_writer = tf.summary.FileWriter('log_simple_stats', sess.graph)
sess.run(tf.global_variables_initializer())
for i in range(100):
summary_writer.add_summary(sess.run(summaries), i)
sess.run(train_step)
最新文章
- jQuery版AJAX简易封装
- Collection和Collections的区别?
- ipython notebook设置工作路径和自动保存.py文件 ipython_notebook_config.py
- <;雨季>;
- (ios实战) UINavigationBar 返回按钮 文本自定义实现
- C# WinForm 透明控件 PictureBox透明 分类: WinForm 2014-07-30 13:27 591人阅读 评论(0) 收藏
- BZOJ1634: [Usaco2007 Jan]Protecting the Flowers 护花
- rapidjson 使用教程
- 对JS prototype的理解
- 微信小程序注意点与快捷键
- 在IIS中如何配置SSL(https)
- java 静态变量 静态代码块 加载顺序问题
- ASP.NET MVC - XML节点查找
- 如何利用 Git 与 GitHub 进行多人协作开发
- bzoj4444 国旗计划
- Windows 7 系统中开启 ASP.NET State Service 服务的方法
- OC ARC之循环引用问题(代码分析)
- node auto run / node 自动运行
- 深入浅出JavaScript之跨域总结
- Nginx随笔
热门文章
- C# 报表和打印等
- Linux下安装并配置SSH服务
- java基础—static关键字
- js cookie 操作
- Golang 简单 http 代理转发
- NodeJS基础API-path相关的问题basename,extname,dirname,parse,format,sep,delimiter,win32,posix
- LeetCode之Weekly Contest 92
- 前端MVVM模式及其在Vue和React中的体现
- OpenCV编译 Make出错 recipe for target &#39;modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/all&#39; failed
- Thonny -- 简洁的 python 轻量级 IDE