当前位置:网站首页>Station B Liu Erden - linear regression and gradient descent
Station B Liu Erden - linear regression and gradient descent
2022-07-06 05:42:00 【Ning Ranye】
List of articles
《PyTorch Deep learning practice 》 Complete the collection -B Stand up, Mr. Liu er
Pytorch Details of code attention , Easy to hit the wrong place
B Stand up, Mr. Liu er - Back propagation Lecture 3
B Stand up, Mr. Liu er - Linear regression Pytorch Lecture 4
List of articles
Preface
Lecture 3
The graph of self written code is a straight line , reason : Learning rate alpha Set too large , from 0.1 Set to 0.005 It will become a curve
One 、 Code
import matplotlib.pyplot as plt
import torch
import numpy as np
import csv
import os
x_data = [1.0, 2.0, 3.0]
y_data = [2.0, 4.0, 6.0]
def forward(x,w):
return x*w
def gradient(xs, ys,w):
grad = 0
for(x,y) in zip(xs,ys):
grad += (x*w-y)*x
grad = 2*grad/len(xs)
return grad
def loss(xs, ys, w):
los = 0
for(x,y) in zip(xs,ys):
los += (x*w-y)*(x*w-y)
los = los/len(xs)
return los
w_list = []
mse_list = []
alpha = 0.1
w = 1.0
ite = 100
for i in range(ite):
los = loss(x_data, y_data, w)
mse_list.append(los / 3.0)
w_list.append(w)
w = w - alpha*gradient(x_data, y_data, w)
plt.plot(w_list,mse_list)
plt.xlabel("w")
plt.ylabel("mse")
plt.show()
Above learning rate 0.1
Upper figure : Learning rate 0.005
边栏推荐
- HAC cluster modifying administrator user password
- Figure database ongdb release v-1.0.3
- Improve jpopup to realize dynamic control disable
- Notes, continuation, escape and other symbols
- 指針經典筆試題
- 2022半年总结
- Self built DNS server, the client opens the web page slowly, the solution
- Graduation design game mall
- LeetCode_字符串反转_简单_557. 反转字符串中的单词 III
- 27io stream, byte output stream, OutputStream writes data to file
猜你喜欢
自建DNS服务器,客户端打开网页慢,解决办法
Deep learning -yolov5 introduction to actual combat click data set training
类和对象(一)this指针详解
Unity Vector3. Use and calculation principle of reflect
[Jiudu OJ 08] simple search x
初识数据库
Sword finger offer II 039 Maximum rectangular area of histogram
05. Security of blog project
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Vulhub vulnerability recurrence 69_ Tiki Wiki
随机推荐
UCF (2022 summer team competition I)
The digital economy has broken through the waves. Is Ltd a Web3.0 website with independent rights and interests?
B站刘二大人-多元逻辑回归 Lecture 7
Notes, continuation, escape and other symbols
Problems encountered in installing mysql8 on MAC
YYGH-11-定时统计
Fluent implements a loadingbutton with loading animation
How to get list length
ARTS Week 25
[detailed explanation of Huawei machine test] statistics of shooting competition results
巨杉数据库再次亮相金交会,共建数字经济新时代
27io stream, byte output stream, OutputStream writes data to file
Yygh-11-timing statistics
Improve jpopup to realize dynamic control disable
Vulhub vulnerability recurrence 67_ Supervisor
js Array 列表 实战使用总结
Installation de la Bibliothèque de processus PDK - csmc
PDK process library installation -csmc
B站刘二大人-反向传播
应用安全系列之三十七:日志注入