当前位置:网站首页>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 ,
边栏推荐
- Docker configuring MySQL Cluster
- Wu Enda linear regression of machine learning
- 反射机制的原理是什么?
- Interpretation of the standard of software programming level examination for teenagers_ second level
- Learning notes: what are the common array APIs that change the original array or do not change the original array?
- Sublime install plug-ins
- 数通基础-网络基础知识
- Apple dominates, Samsung revives, and domestic mobile phones fail in the high-end market
- Mysql5.7.25 master-slave replication (one-way)
- Netease cloud UI imitation -- & gt; sidebar
猜你喜欢
Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
Interview shock 68: why does TCP need three handshakes?
服务发现原理分析与源码解读
Solve NPM -v sudden failure and no response
Okaleido生态核心权益OKA,尽在聚变Mining模式
Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
数通基础-二层交换原理
服务器内存故障预测居然可以这样做!
Use of tabbarcontroller
Basics of data communication - basic knowledge of network
随机推荐
Study notes of the third week of sophomore year
Due to fierce competition in the new market, China Mobile was forced to launch a restrictive ultra-low price 5g package
Vs2019 configuring opencv
PHP one-time request lifecycle
分布式网络通信框架:本地服务怎么发布成RPC服务
Reproduce the snake game in C language (I) build pages and construct snakes
Netease cloud UI imitation -- & gt; sidebar
Sublime install plug-ins
Applet record
Study on the basis of opencv
Leetcode 504. 七进制数
【有奖提问】向图灵奖得主、贝叶斯网络之父 Judea Pearl 提问啦
Vectortilelayer replacement style
Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
Learning about opencv (2)
C language course design Tetris (Part 2)
AirTest
Solution of inputting whole line string after inputting integer
Use of tabbarcontroller
What is the principle of reflection mechanism?