当前位置:网站首页>Machine learning deep learning -- Vectorization
Machine learning deep learning -- Vectorization
2022-06-25 04:37:00 【Hair will grow again without it】
To quantify
Whenever possible, avoid explicit for-loops.
Why vectorization
Speed up the operation , This requires a powerful toolkit numpy
Go directly to the code to see the comparison between non vectorization and vectorization Calculation The inner product of two vectors , You can see , The result of vectorization is 300 times faster than that of non vectorization
More examples of vectorization
A matrix is multiplied by a vector 
Calculate the exponent of a vector 
Apply vectorization to logistic In the regression
Non vectorization logistic Regression gradient descent code :
In this code There are two cycles , Part of the green indication , In the calculation dw When , If we have multiple eigenvalues , You have to calculate multiple dw, here n=2,dw Just count two , Most of the time, it is necessary to use a cycle to solve , But in order not to cycle , Change the following code to a vector
take dw1,dw2 … Change it to a vector dw Express , initialization dw by n_x That's ok 1 Column 0 that will do
To quantify logistic Return to
In the vectorization above , It simplifies the intermediate requirements dw The cycle of , here , take for i=1 to m Also simplified , To quantify
Here's how :
First ask for z1,z2 etc. , from z = wTx + b You know , Should first w,x and b To quantify ,x Is the number of input eigenvalues , Write it down as nx, Each sample corresponds to a different input , altogether m Samples , So there is m Column , therefore x yes R(nx,m) Matrix , and w I already know it is a R(nx,1) Matrix ,w*x The resulting matrix is R(1*m) Of , therefore b It's also R(1*m) Of , Lastz = np.dot(w.t, X) + b
And then calculate a1,a2 etc. ,a Is a pair of activation functions z Obtained , When z Have worked out , You can directly put the vector into the activation function to find the vector a, LastA = σ(Z)
To quantify logistic Gradient output of regression
And then there's the calculation dz,db,dw
Last , Apply vectorization to logistic The gradient output of regression goes
边栏推荐
- GBASE 8s 索引B+树
- Structure syntaxique des procédures stockées gbase 8S
- 515. find the maximum value / Sword finger offer II 095 in each tree row Longest common subsequence
- Win10 environment phpstudy2016 startup failure record
- Value transfer between parent and child components of wechat applet
- Laravel document sorting 4. Controller
- Gbase 8s overall architecture
- 2020.3.3 notes async/await and promise and Then processes and threads
- PHP extracts and analyzes table contents, and collects bidding information
- 冰冰学习笔记:循环队列的实现
猜你喜欢

What is the storage engine and the three common database storage engines for MySQL

【esp32学习之路6——flash加密】

CTF_ Web:8-bit controllable character getshell

unity Quad剔除背面并剔除透明部分的shader

Vscode 设置clang-format

PHP extracts and analyzes table contents, and collects bidding information

领导:谁再用 Redis 过期监听实现关闭订单,立马滚蛋!

Unity Quad culls shaders with back faces and transparent parts

Coinlist queuing tutorial to improve the winning rate

《牛客刷verilog》Part I Verilog快速入门
随机推荐
Immutable學習之路----告別傳統拷貝
重磅直播 | 相移法+多频外差之数学原理推导+实现
简单的恶意样本行文分析-入门篇
js的arguments
BSC smart contract dividend mainstream currency | including marketing wallet | deflation | reflow | dividend free token | available for direct deployment
OOP栈类模板(模板+DS)
深度学习——几种学习类型
GBASE 8s的并行操作问题场景描述
i. Max development board learning record
kenlm
Anaconda installation +tensorflow installation +keras installation +numpy installation (including image and version information compatibility issues)
CTF_ Web: deserialization learning notes (I) classes and objects in PHP
How to screen out words related to products and eliminate invalid words accurately
Use of deferred environment variable in gbase 8s
三角形类(构造与析构)
Laravel document sorting 2. Route related
Gbase 8s parallel operation problem scenario description
halcon之区域:多种区域(Region)生成(3)
GBASE 8s的数据导入和导出
CTF_ Web:php weak type bypass and MD5 collision





