当前位置:网站首页>[machine learning] vectorized computing -- a must on the way of machine learning
[machine learning] vectorized computing -- a must on the way of machine learning
2022-07-01 02:52:00 【Computer magician】
Welcome to
Magic house !!The article contains columns
— machine learning —Column content
— 【 machine learning 】 On the normal equation method & gradient descent —
— 【 machine learning 】 Data standardization of gradient descent —
— 【 machine learning 】logistic Classification regression algorithm —
— The 10th “ Teddy cup “ Thank you for learning summary —
【 machine learning 】 Vectorization --- The only way to machine learning
One 、 Solving the matrix
In solving the matrix , There are often many good , Highly optimized linear algebra library , Such as octave,matlib,python numpy, c++,java.
We use these linear algebra libraries , It can be implemented in just a few lines Desired effect .
Read this article ( Need a little knowledge of Linear Algebra )
Two 、 Patients with a
for example Find the formula :
h ( x ) = ∑ i = 1 n θ i ∗ x i h(x) = \sum_{i=1}^n\theta_i*x_i h(x)=∑i=1nθi∗xi
We can cycle through each value to find every last i i i The corresponding result is , But the time complexity of the cycle is O ( n ) O(n) O(n) , We can θ i ( i = 1 , 2 , 3... n ) \theta_i(i=1,2,3...n) θi(i=1,2,3...n) See as n n n The column vector of dimension , x i x_i xi As n n n The column vector of dimension , Then the original formula is to find the inner product of two vectors θ T ∗ x i \theta^T*x_i θT∗xi To find the equation , In this way numpy You only need one line of code in . Here's the picture ( The demo code is octave(matlib Open source Edition ))
c++ Realization 
3、 ... and 、 Example 2
- Let's take a more complicated example :
( I don't know about gradient descent yet. I suggest you eat the article first : machine learning 】 On the normal equation method & gradient descent )
In gradient descent (Gradient descent) Synchronize updates Parameters θ i ( i = 1 , 2 , 3... m ) in \theta_i(i=1,2,3...m) in θi(i=1,2,3...m) in

We can go through the loop i i i Get each parameter update , But can we use the method of example 1 Simplification ,
Pictured :
Let's change the equation to The operation between vectors ,
θ = θ − α ∗ δ \theta = \theta - \alpha * δ θ=θ−α∗δ
( among : δ δ δ = ∑ x = 1 n ( h θ ( x ) − y i ) 2 n ∗ x i \sum_{x=1}^n \frac{(h_\theta(x) - y_i)^2}{ n }*x_i ∑x=1nn(hθ(x)−yi)2∗xi, h θ ( x ) − y i h_\theta(x) - y_i hθ(x)−yi It's a real number , x i x_i xi Is the column vector of the feature dimension )
Now the parameters θ i \theta_i θi It can also be updated synchronously , Meet the requirements
Four 、 At the end
In the face of , The data is at the level of millions , Ten million levels , Or feature millions , Feature level , Vectorization It is very efficient to improve the operation efficiency , Than
forLoops are much better to use , This is very common in machine learning , Be sure to master
边栏推荐
- Mouse over effect IV
- Share Creators萌芽人才培养计划来了!
- robots. Txt restrict search engine inclusion
- JS to find duplicate elements in two arrays
- 鼠标悬停效果八
- js中的图片预加载
- Share Creators萌芽人才培養計劃來了!
- Detailed explanation of pointer array and array pointer (comprehensive knowledge points)
- Classic programming problem: finding the number of daffodils
- LeetCode_栈_困难_227.基本计算器(不含乘除)
猜你喜欢

Contrastive learning of Class-agnostic Activation Map for Weakly Supervised Object Localization and

视觉特效,图片转成漫画功能

【小程序项目开发-- 京东商城】uni-app之首页商品楼层

Applet custom top navigation bar, uni app wechat applet custom top navigation bar
![Servlet [first introduction]](/img/2a/aff3b93e43550d30a33c1683210d3a.png)
Servlet [first introduction]

Pychart software deployment gray unable to point

Pulsar的Proxy支持和SNI路由

Pychar open remote directory remote host

小程序自定义顶部导航栏,uni-app微信小程序自定义顶部导航栏

Gartner research: in China, the adoption of hybrid cloud has become the mainstream trend
随机推荐
RestCloud ETL实践之无标识位实现增量数据同步
C language a little bit (may increase in the future)
Mouse over effect 9
In the industrial Internet, "small" programs have "big" effects
Xception learning notes
【微信小程序开发】样式汇总
详解数据治理知识体系
7_ Openresty installation
鼠标悬停效果七
查看 jvm 参数
Complete training and verification of a neural network based on pytorch
Restcloud ETL data realizes incremental data synchronization through timestamp
鼠标悬停效果十
How to open a stock account? Also, is it safe to open an account online?
单片机 MCU 固件打包脚本软件
UE4 rendering pipeline learning notes
【小程序项目开发-- 京东商城】uni-app之首页商品楼层
Pulsar Geo Replication/灾备/地域复制
Proxy support and SNI routing of pulsar
彻底解决Lost connection to MySQL server at ‘reading initial communication packet
