莫烦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 ...
随机推荐
- 文本统计器(Java)
1. 创建一个类,实现统计文本文件中各类字符和字符串的个数的功能,要求实现: a) 按字符统计,输出各个字符的数量 b) 按单词统计,输出各个单词的数量 2. 在b)的基础上实现一个类keywordI ...
- 创建xml树
XMLElement 节点XMLDocument 节点的CUID操作 XMLNode 抽象类 操作节点 (XMLElement XMLDocument ) XElement xElement = ne ...
- GitHub学习二-将本地Git库与Github上的Git库相关联
0 git clone 如果是从自己的github clone,一键搞定,和三步的git remote add功能一样. 1.创建本地库 新建目录,右键git bash here,输入 git ini ...
- 基于Vue + webpack + Vue-cli 实现分环境打包项目
需求由来:我公司项目上线发布至服务器分为三个环境分别为测试环境.预发布环境.生产环境:前期做法是项目通过脚步打包时由脚步把域名和后缀名之类的全部替换成要发布的环境所需要的,因为我公司的项目比较大由许许 ...
- 使用maven构建一个web项目
使用maven构建一个web项目 首先建立一个maven项目(关于环境配置上节有详细过程): 1)-->右键new,-->project ...
- #pragma 处理警告 clang diagnostic 的使用
首先#pragma在本质上是声明,常用的功能就是注释,尤其是给Code分段注释:而且它还有另一个强大的功能是处理编译器警告,但却没有上一个功能用的那么多. clang diagnostic 是#pra ...
- 使用机器学习检测TLS 恶意加密流——业界调研***有开源的数据集,包括恶意证书的,以及恶意tls pcap报文***
2018 年的文章, Using deep neural networks to hunt malicious TLS certificates from:https://techxplore.com ...
- Spring AOP+Log4j记录项目日志
转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6567672.html 项目日志记录是项目开发.运营必不可少的内容,有了它可以对系统有整体的把控,出现任何问题 ...
- 码云git使用三(本地代码合并)
现在我们已经学会了把“本地代码上传至码云git服务器”和“从码云git服务器下载代码到本地”. 我们现在学习怎么上传代码到服务器注意事项和步骤. 1.我们修改代码后,我们需要先+Add后再Commit ...
- python 利用turtle库绘制七段数码管的方式,绘制当前事件(时分秒00:00:00)
# coding:utf-8# 绘制七段数码管,显示当前时间import timeimport turtle as tt # 绘制间隔def drawGap(): tt.penup() tt.fd(3 ...