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

边栏推荐
- MySQL function
- [fluorescent character effect]
- Session based recommendations with recurrent neural networks
- Wechat H5 payment on WAP, for non wechat browsers
- Solution of inputting whole line string after inputting integer
- All codes of Tetris
- Strange Towers of Hanoi|汉诺塔4柱问题
- Wechat applet learning notes 1
- Use of pclint in vs2013
- Cloud native (36) | introduction and installation of harbor in kubernetes
猜你喜欢

点赞,《新程序员》电子书限时免费领啦!

新建福厦铁路全线贯通 这将给福建沿海带来什么?

2022年中科磐云——服务器内部信息获取 解析flag

Like, "new programmer" e-book is free for a limited time!

SSG framework Gatsby accesses the database and displays it on the page

Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration

SQL优化的魅力!从 30248s 到 0.001s

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

服务发现原理分析与源码解读
![Azkaban [basic knowledge 01] core concepts + features +web interface + Architecture +job type (you can get started with Azkaban workflow scheduling system in one article)](/img/f9/c86ccbb0967894d370498c3a9630eb.png)
Azkaban [basic knowledge 01] core concepts + features +web interface + Architecture +job type (you can get started with Azkaban workflow scheduling system in one article)
随机推荐
AR model in MATLAB for short-term traffic flow prediction
Set view dynamic picture
regular expression
Principle analysis and source code interpretation of service discovery
In Net 6.0
服务发现原理分析与源码解读
新建福厦铁路全线贯通 这将给福建沿海带来什么?
Common errors when starting projects in uniapp ---appid
Encapsulation of tabbarcontroller
网易云UI模仿-->侧边栏
B站这个视频我是跪着看完的
【有奖提问】向图灵奖得主、贝叶斯网络之父 Judea Pearl 提问啦
protobuf的基本用法
点赞,《新程序员》电子书限时免费领啦!
Vectortilelayer replacement style
服务器内存故障预测居然可以这样做!
Under win10 64 bit, matlab fails to configure notebook
Flask框架初学-03-模板
Data communication foundation TCPIP reference model
Study notes of the third week of sophomore year