当前位置:网站首页>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 ,

边栏推荐
- 挡不住了,纯国产PC已就位,美国的软硬件体系垄断正式被破
- Force deduction DFS
- Getting started with SQL - combined tables
- Interview shock 68: why does TCP need three handshakes?
- Beginner of flask framework-04-flask blueprint and code separation
- Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
- The fourth week of summer vacation
- Matlab Simulink realizes fuzzy PID control of time-delay temperature control system of central air conditioning
- Formwork (III)
- How to write a million reading article
猜你喜欢

Meeting OA project (III) -- my meeting (meeting seating and submission for approval)

Xiaobai makes a wave of deep copy and shallow copy

Principle analysis and source code interpretation of service discovery

【有奖提问】向图灵奖得主、贝叶斯网络之父 Judea Pearl 提问啦

Transform between tree and array in JS (hide the children field if the child node of the tree is empty)

Common errors when starting projects in uniapp ---appid
![[MySQL database] a collection of basic MySQL operations - the basis of seeing (adding, deleting, modifying, and querying)](/img/a7/b3bb6f584dff0eb9b49e81e5b9dade.png)
[MySQL database] a collection of basic MySQL operations - the basis of seeing (adding, deleting, modifying, and querying)
![Sqoop [environment setup 01] CentOS Linux release 7.5 installation configuration sqoop-1.4.7 resolve warnings and verify (attach sqoop 1 + sqoop 2 Latest installation package +mysql driver package res](/img/8e/265af6b20f79b21c3eadcd70cfbdf7.png)
Sqoop [environment setup 01] CentOS Linux release 7.5 installation configuration sqoop-1.4.7 resolve warnings and verify (attach sqoop 1 + sqoop 2 Latest installation package +mysql driver package res

On the compilation of student management system of C language course (simple version)

如何写一篇百万阅读量的文章
随机推荐
AirTest
C language course design Tetris (Part 1)
面试突击68:为什么 TCP 需要 3 次握手?
Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
Use of tabbarcontroller
JS continuous assignment operation
新建福厦铁路全线贯通 这将给福建沿海带来什么?
Strange Towers of Hanoi|汉诺塔4柱问题
Rowselection emptying in a-table
Production of a-modal drag function in antui
Use of pclint in vs2013
Data communication foundation TCPIP reference model
2021年山东省中职组“网络空间安全”B模块windows渗透(解析)
Getting started with SQL - combined tables
在.NET 6.0中配置WebHostBuilder
Why does new public chain Aptos meet market expectations?
Force deduction DFS
The fourth week of summer vacation
C language course design Tetris (Part 2)
Solve NPM -v sudden failure and no response