当前位置:网站首页>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
边栏推荐
- Laravel document sorting 10. Request life cycle
- jsz中的join()
- 简单的恶意样本行文分析-入门篇
- Sourcetree pulls the code and prompts to fill in authentic, but the configuration cannot change the user
- GBASE 8s活锁、死锁问题的解决
- Codeforces Round #802 (Div. 2) C D
- OOP栈类模板(模板+DS)
- Unity Quad culls shaders with back faces and transparent parts
- GBASE 8s的并行操作问题场景描述
- What is the storage engine and the three common database storage engines for MySQL
猜你喜欢

Cnpm: unable to load file c:\users\administrator\appdata\roaming\npm\cnpm PS1 because running scripts is prohibited on this system.

LabVIEW development gas regulator

马斯克发布人形机器人,AI对马斯克为什么意义重大?

Office macro virus bounce shell experiment

CTF_ Web: basic 12 questions WP of attack and defense world novice zone

jsz中的join()

微信小程序父子组件之间传值

论文笔记: 多标签学习 ESMC (没看懂, 还没写出来, 暂时放这里占个位置)

js中的concat()

CTF_ Web: advanced problem WP (5-8) of attack and defense world expert zone
随机推荐
计算学生成绩等级(虚函数和多态)
php封装curl发送get、post请求方法,并使用
Comparison of towe/ JIRA / tapd / Zen collaboration platforms
什么是数据持久化?
Anaconda安装+TensorFlow安装+Keras安装+numpy安装(包含镜像和版本信息兼容问题)
GBASE 8s的触发器
unity Quad剔除背面并剔除透明部分的shader
写shell脚本报错总结
LabVIEW development gas regulator
Laravel document sorting 7. View
js的call()和apply()
Gbase 8s stored procedure syntax structure
Gbase 8s overall architecture
论文笔记: 多标签学习 ESMC (没看懂, 还没写出来, 暂时放这里占个位置)
Anaconda installation +tensorflow installation +keras installation +numpy installation (including image and version information compatibility issues)
使用文本分析识别一段文本中的主要性别
Thorough understanding of database transactions
Solution of gbase 8s livelock and deadlock
OOP 向量加减(友元+拷贝构造)
Retrofit 源码分析





