当前位置:网站首页>Learning about tensorflow (I)
Learning about tensorflow (I)
2022-07-26 10:13:00 【SingleDog_ seven】
tensorFlow It's based on Data stream programming (dataflow programming) Symbolic mathematics system of , It is widely used in all kinds of machine learning (machine learning) Programming implementation of algorithm , Its predecessor is Google A library of neural network algorithms DistBelief
Tensorflow It has a multi-level structure , It can be deployed in various fields The server 、PC Terminals and Webpage And support GPU and TPU High performance Numerical calculation , It is widely used in product development and scientific research in various fields within Google .
TensorFlow By Google Artificial intelligence The team Google brain (Google Brain) Development and maintenance , Ownership includes TensorFlow Hub、TensorFlow Lite、TensorFlow Research Cloud A number of projects and all kinds of Application program interface (Application Programming Interface, API). since 2015 year 11 month 9 The date of ,TensorFlow basis Apache licensing agreement (Apache 2.0 open source license) Open source
tensorflow The essence of Large scale computing framework , Its operation can be abstracted as an operational vector graph .
Let's first look at the operation of linear problems :
With y = w* x +b For example :
seek loss, Least square method
# y = wx +b
# Calculation loss
def compute_error_fow_line_given_points(b,w,points): #b,w Is an initialized value ,points yes ( Can be seen as ) An array
totalError =0
for i in range(0,len(points)):
x=points[i,0]
y=points[i,1]
totalError +=(y-(w*x+b))**2
return totalError/float(len(points))loss Value can also be said to be loss value , The smaller the better.
def step_gradient(b_current,w_current,points,learningRate):
b_gradient = 0
w_gradient = 0
N = float(len(points))
for i in range(0,len(points)):
x = points[i,0]
y = points[i,1]
#grad_b = 2(wx+b-y)
b_gradient+=(2/N)*((w_current*x+b_current)-y)
# grad_w = (wx+b-y)*x
w_gradient+=(2/N)*x*((w_current*x+b_current)-y)
new_b =b_current-(learningRate*b_gradient)
new_w =w_current-(learningRate*w_gradient)
return [new_b,new_w]This is asking w and b Value , Under multiple cycles ,w,b Will approach the real value .
# Number of cycles
def gradient(points,staring_b,stating_w,learning_rate,num_iterating):
b = staring_b
w = stating_w
for i in range(num_iterating):
b,w=step_gradient(b,w,np.array(points),learning_rate)
return [b,w]Number of cycles , The more cycles , The higher the exact value .
def run():
points =np.genfromtxt(" data ",delimiter=',')
learning_rate = 0.0001
# initialization
initial_b =0
initial_w =0
num_iterations =1000
print("Staring gradient dscent at b={0},w={1},error={2}"
.format(initial_b,initial_w,
compute_error_fow_line_given_points(initial_b,initial_w,points)))
print('/n')
[b,w] = gradient(points,initial_b,initial_w,learning_rate,num_iterations)
print("After{0} iterations b={1},w={2},error={3}"
.format(num_iterations,b,w,compute_error_fow_line_given_points(b,w,points)))function , We can see all the data , obtain w,b.
Linear regression is the simplest part of machine learning , It's also the beginning ,

边栏推荐
- Production of a-modal drag function in antui
- Rowselection emptying in a-table
- On the compilation of student management system of C language course (simple version)
- 分布式网络通信框架:本地服务怎么发布成RPC服务
- 网易云UI模仿-->侧边栏
- Flutter Event 派发
- SSG framework Gatsby accesses the database and displays it on the page
- Data communication foundation - layer 2 switching principle
- El table implements adding / deleting rows, and a parameter changes accordingly
- Study notes of the first week of sophomore year
猜你喜欢

2021 windows penetration of "Cyberspace Security" B module of Shandong secondary vocational group (analysis)

Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)

Vs Code configures go locale and successfully installs go related plug-ins in vscode problem: Tools failed to install

新增市场竞争激烈,中国移动被迫推出限制性超低价5G套餐

2021年山东省中职组“网络空间安全”B模块windows渗透(解析)

数通基础-网络基础知识

Distributed network communication framework: how to publish local services into RPC services
![Uniapp common error [wxml file compilation error]./pages/home/home Wxml and using MySQL front provided by phpstudy to establish an independent MySQL database and a detailed tutorial for independent da](/img/21/5dceab9815b503f0b62d26a430d7eb.png)
Uniapp common error [wxml file compilation error]./pages/home/home Wxml and using MySQL front provided by phpstudy to establish an independent MySQL database and a detailed tutorial for independent da

Uniapp error 7 < Map >: marker ID should be a number
![[award-winning question] ask Judea pearl, the Turing prize winner and the father of Bayesian networks](/img/0f/01d6e49fff80a325b667784e40bff3.png)
[award-winning question] ask Judea pearl, the Turing prize winner and the father of Bayesian networks
随机推荐
Study notes of the third week of sophomore year
数通基础-Telnet远程管理设备
Docker configuring MySQL Cluster
SQL Server 2008 R2 installation problems
IE7 set overflow attribute failure solution
2022 zhongkepan cloud - server internal information acquisition and analysis flag
The charm of SQL optimization! From 30248s to 0.001s
The diagram of user login verification process is well written!
Apple dominates, Samsung revives, and domestic mobile phones fail in the high-end market
Use of pclint in vs2013
Installation and use of cocoapods
Distributed network communication framework: how to publish local services into RPC services
数通基础-TCPIP参考模型
AirTest
[MySQL database] a collection of basic MySQL operations - the basis of seeing (adding, deleting, modifying, and querying)
Interview shock 68: why does TCP need three handshakes?
新增市场竞争激烈,中国移动被迫推出限制性超低价5G套餐
解释一下自动装箱和自动拆箱?
2021年山东省中职组“网络空间安全”B模块windows渗透(解析)
Interpretation of the standard of software programming level examination for teenagers_ second level