TensorFlow1.0 线性回归
import tensorflow as tf
import numpy as np #create data x_data = np.random.rand(100).astype(np.float32)
y_data = x_data*0.1+0.3 Weights = tf.Variable(tf.random_uniform([1],-1.0,1.0))
biases = tf.Variable(tf.zeros([1])) y = Weights*x_data+biases
loss = tf.reduce_mean(tf.square(y-y_data)) optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)
init = tf.initialize_all_variables() sess = tf.Session()
sess.run(init) for step in range(201):
sess.run(train)
if step % 20 ==0:
print(step,sess.run(Weights),sess.run(biases)) 0 [0.7417692] [-0.07732911]
20 [0.30772722] [0.18689097]
40 [0.16603212] [0.26404503]
60 [0.12099022] [0.28857067]
80 [0.10667235] [0.29636687]
100 [0.10212099] [0.2988451]
120 [0.10067423] [0.29963288]
140 [0.10021434] [0.2998833]
160 [0.10006816] [0.2999629]
180 [0.10002167] [0.2999882]
200 [0.10000689] [0.29999626]
TensorFlow1.0 线性回归的更多相关文章
- Ubuntu14.10安装TensorFlow1.0.1
本文记录了在Ubuntu上安装TensorFlow的步骤.系统环境:Ubuntu14.10 64bitPython版本:Python 2.7.8TensorFlow版:TensorFlow 1.0.1 ...
- 初用Linux, 安装Ubuntu16.04+NVIDIA387+CUDA8.0+cudnn5.1+TensorFlow1.0.1
因为最近Deep Learning十分热门, 装一下TensorFlow学习一下. 本文主要介绍安装流程, 将自己遇到的问题说明出来, 并记录自己如何处理, 原理方面并没有能力解释. 由于本人之前从来 ...
- tensorflow1.0.0 弃用了几个operator写法
除法和取模运算符(/, //, %)现已匹配 Python(flooring)语义.这也适用于 tf.div 和 tf.mod.为了获取强制的基于整数截断的行为,你可以使用 tf.truncatedi ...
- tensorflow1.0中的改善
TensorFlow 1.0 重大功能及改善 XLA(实验版):初始版本的XLA,针对TensorFlow图(graph)的专用编译器,面向CPU和GPU. TensorFlow Debugger(t ...
- tensorflow1.0 队列FIFOQueue管理实现异步读取训练
import tensorflow as tf #模拟异步子线程 存入样本, 主线程 读取样本 # 1. 定义一个队列,1000 Q = tf.FIFOQueue(1000,tf.float32) # ...
- tensorflow1.0 数据队列FIFOQueue的使用
import tensorflow as tf #模拟一下同步先处理数据,然后才能取数据训练 #tensorflow当中,运行操作有依赖性 #1.首先定义队列 Q = tf.FIFOQueue(3,t ...
- tensorflow1.0 lstm学习曲线
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt BATCH_START = 0 TIME_STEP ...
- tensorflow1.0 构建lstm做图片分类
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data #this is data mni ...
- tensorflow1.0 dropout层
""" Please note, this code is only for python 3+. If you are using python 2+, please ...
随机推荐
- Java 注解 So Easy!!!
Java注解 Annotations, a form of metadata, provide data about a program that is not part of the program ...
- coding++:win10家庭版升级专业版方案
win10家庭版升级专业版密钥: VK7JG-NPHTM-C97JM-9MPGT-3V66T 4N7JM-CV98F-WY9XX-9D8CF-369TT FMPND-XFTD4-67FJC-HDR8C ...
- 算法(algorithm)
算法是什么? 算法是指令的集合,是为解决特定问题而规定的一系列操作. 它是明确定义的可计算过程,以一个数据集合作为输入,并产生一个数据集合作为输出. 一个算法通常来说具有以下五个特性: 1.输入:一个 ...
- Sql练习201908131742
orderdt_jimmy表结构: sql查询: then amount end) t1, then amount end) t2, then amount end) t3 from orderdt_ ...
- JavaScript简单使用
本文参考廖雪峰老师网站:https://www.liaoxuefeng.com/wiki/1022910821149312 JavaScript是一种运行在浏览器中的解释型的编程语言,在Web世界里, ...
- 使用 Spring data redis 结合 Spring cache 缓存数据配置
使用 JavaConfig 方式配置 依赖 jar 包: jedis.spring-data-redis 首先需要进行 Redis 相关配置 @Configuration public class R ...
- const不同位置带来的区别
const不同位置带来的区别 今天同学问我数据结构时,我对以下代码懵了一下: template <class T> class Link{ public: T data; Link< ...
- find的基本查询命令《一》
一. find的基本查询命令 find命令最常用的是查找某个文件,如: find ./ -name "abc.txt" 则会在当前目录及子目录下查找abc.txt文件 更常用的是查 ...
- ASP.NET Core中的Controller
ASP.NET CORE出现之前我们实现的Controller,MVC都继承自Controller基类,WebApi的话继承自ApiController.现在ASP.NET CORE把MVC跟WebA ...
- 路由与交换,cisco路由器配置,浮动静态路由
设置浮动静态路由的目的就是为了防止因为一条线路故障而引起网络故障.言外之意就是说浮动静态路由实际上是主干路由的备份.例如下图: 假如我们设路由器之间的串口(seria)为浮动静态路由(管理距离为100 ...