莫烦tensorflow(1)-训练线性函数模型
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
####create tensorflow structure start###
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()
####create tensorflow structure end###
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))
莫烦tensorflow(1)-训练线性函数模型的更多相关文章
- 莫烦tensorflow(5)-训练二次函数模型并用matplotlib可视化
import tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt def add_layer(inputs,in_siz ...
- 莫烦tensorflow(9)-Save&Restore
import tensorflow as tfimport numpy as np ##save to file#rember to define the same dtype and shape w ...
- 莫烦tensorflow(8)-CNN
import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data#number 1 to 10 dat ...
- 莫烦tensorflow(7)-mnist
import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data#number 1 to 10 dat ...
- 莫烦tensorflow(6)-tensorboard
import tensorflow as tfimport numpy as np def add_layer(inputs,in_size,out_size,n_layer,activation_f ...
- 莫烦tensorflow(4)-placeholder
import tensorflow as tf input1 = tf.placeholder(tf.float32)input2 = tf.placeholder(tf.float32) outpu ...
- 莫烦tensorflow(3)-Variable
import tensorflow as tf state = tf.Variable(0,name='counter') one = tf.constant(1) new_value = tf.ad ...
- 莫烦tensorflow(2)-Session
import os os.environ['TF_CPP_MIN_LOG_LEVEL']='2' import tensorflow as tfmatrix1 = tf.constant([[3,3] ...
- tensorflow学习笔记-bili莫烦
bilibili莫烦tensorflow视频教程学习笔记 1.初次使用Tensorflow实现一元线性回归 # 屏蔽警告 import os os.environ[' import numpy as ...
随机推荐
- 第二阶段——个人工作总结DAY06
1.昨天做了什么:昨天做完了修改密码的界面.(有点丑) 2.今天打算做什么:今天制作时间轴. 3.遇到的困难:无.
- centos7 mysql+MHA高可用安装
https://dzone.com/articles/consul-proxysql-and-mysql-ha?utm_medium=feed&utm_source=feedpress.me& ...
- 完全揭秘log file sync等待事件-转自itpub
原贴地址:http://www.itpub.net/thread-1777234-1-1.html 谢谢 guoyJoe 老大 这里先引用一下tanel poder大师的图: 什么是log fil ...
- [poj 2453] An Easy Problem
An Easy Problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8371 Accepted: 5009 D ...
- Java中关键字this、super的含义及使用
Java语言中this的含义及作用: 关键字this用来指向当前实例对象(内存里正在运行的哪个实例对象),它的另一作用是用来区分对象的成员变量与方法的形参. 关键字super指的是当前对象里边的父对象 ...
- koa学习
http://www.ruanyifeng.com/blog/2017/08/koa.html
- js之添加浏览器历史记录
如何生成一条历史记录 简单粗暴的方法,直接在当前页面的地址栏中输入地址 点击页面中有a标签的href 执行location.href = ‘xxx’(location.replace(‘xxx’)生成 ...
- 关于datetimepicker只显示年、月、日的设置
如下是只显示月的sample code: <link rel="stylesheet" href="css/datetimepicker/bootstrap-dat ...
- flask+apache+mod-wsgi部署遇到的坑
首先,看到这种方式部署,我也有疑问,为什么不用nginx,gunicorn.接手的项目,就先按照前人思路run起来. 线上使用ubuntu系统,apache2,而给我玩耍的测试机是centos6.5, ...
- gulp安装和使用
1.全局安装gulp:sudo npm install -g gulp 2.代码根目录:npm install 3.gulp 开始编译(在项目根目录下创建一个名为 gulpfile.js 的文件) 注 ...