tensorflow

1.一切都要tf.

2.只有sess.run才能生效

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt ######################################################
#data
nump_points=1000
vector_set=[]
for i in range(nump_points):
x1=np.random.normal(0.0,0.55)
y1=x1*0.1+0.3+np.random.normal(0.0,0.03)
vector_set.append([x1,y1]) x_data=[v[0] for v in vector_set]
y_data=[v[1] for v in vector_set] plt.scatter(x_data,y_data,c='r')
plt.show()
########################################################
#linear regression
#y=wx+b,initial value
w=tf.Variable(tf.random_uniform([1],-1.0,1.0),name='w')
b=tf.Variable(tf.zeros([1]))
#model
y=w*x_data+b
#trainer set up
loss=tf.reduce_mean(tf.square(y-y_data))
optimizer=tf.train.GradientDescentOptimizer(0.5)
train=optimizer.minimize(loss) sess=tf.Session()
init=tf.global_variables_initializer()
sess.run(init)
#first step
print('w=',sess.run(w),'b=',"loss:",sess.run(loss))
for step in range(20):
sess.run(train)
print('w=', sess.run(w), 'b=', "loss:", sess.run(loss))

1.tensorflow——线性回归的更多相关文章

  1. [tensorflow] 线性回归模型实现

    在这一篇博客中大概讲一下用tensorflow如何实现一个简单的线性回归模型,其中就可能涉及到一些tensorflow的基本概念和操作,然后因为我只是入门了点tensorflow,所以我只能对部分代码 ...

  2. python,tensorflow线性回归Django网页显示Gif动态图

    1.工程组成 2.urls.py """Django_machine_learning_linear_regression URL Configuration The ` ...

  3. tensorflow 线性回归解决 iris 2分类

    # Combining Everything Together #---------------------------------- # This file will perform binary ...

  4. TensorFlow线性回归

    目录 数据可视化 梯度下降 结果可视化 数据可视化 import numpy as np import tensorflow as tf import matplotlib.pyplot as plt ...

  5. tensorflow 线性回归 iris

    线性拟合

  6. TensorFlow简要教程及线性回归算法示例

    TensorFlow是谷歌推出的深度学习平台,目前在各大深度学习平台中使用的最广泛. 一.安装命令 pip3 install -U tensorflow --default-timeout=1800 ...

  7. TensorFlow API 汉化

    TensorFlow API 汉化 模块:tf   定义于tensorflow/__init__.py. 将所有公共TensorFlow接口引入此模块. 模块 app module:通用入口点脚本. ...

  8. tfboys——tensorflow模块学习(三)

    tf.estimator模块 定义在:tensorflow/python/estimator/estimator_lib.py 估算器(Estimator): 用于处理模型的高级工具. 主要模块 ex ...

  9. TensorFlow — 相关 API

    TensorFlow — 相关 API TensorFlow 相关函数理解 任务时间:时间未知 tf.truncated_normal truncated_normal( shape, mean=0. ...

随机推荐

  1. (66) c# async await

    1.使用 async await 2.返回值 static void Main(string[] args) { Program p = new Program(); Console.WriteLin ...

  2. python接口自动化测试三十四:github上某接口测试平台及配置

    TeserHome地址:https://testerhome.com/opensource_projects/60前端:https://github.com/pencil1/ApiTestWeb 实现 ...

  3. cortable 使用方法

    星期一到星期六,早上六点到晚上六点.每隔两个小时 执行语句 0 6-18/2  * * 1-6 commond

  4. InnoDB不支持contains等

    并非所有引擎都支持全文本搜索MySQL.与所有其他的DBMS一样,MySQL具有一个具体管理和处理数据的内部引擎.在你使用CREATE TABLE语句时,该引擎具体创建表,而在你使用SELECT语句或 ...

  5. Linux: 给右键菜单加一个“转换图片为jpg格式”

    Linux上通常都会安装imagemagick这个小巧但又异常强大的工具.这个软件提供了一系列很好用的功能.这里说一说如何使用它的convert命令转换图片为jpg格式,以及如何把它添加到Thunar ...

  6. 笔记72 高级SSM整合

    遇到的问题: 1.进行spring mvc测试的时候报错 测试代码: package com.li.test; import com.github.pagehelper.PageInfo; impor ...

  7. 解决 'express' 不是内部或外部命令,也不是可运行的程序

    express-generator >npm install -g express-generator 就可以了

  8. 目标检测中roi的有关操作

    1.roi pooling 将从rpn中得到的不同Proposal大小变为fixed_length output, 也就是将roi区域的卷积特征拆分成为H*W个网格,对每个网格进行maxpooling ...

  9. dosbox下载并配置BC3.1及环境变量的方法

    https://www.tuicool.com/articles/v2A3mm--Win8下用DOSBox编写汇编语言 http://www.dosbox.com/ http://www.masm32 ...

  10. eclipse设置tomcat部署目录地址

    参考: https://blog.csdn.net/lvyuan1234/article/details/53418818 右键,open 操作前提是所有项目移除,并且右键clean掉相关数据! 修改 ...