当前位置:网站首页>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
边栏推荐
- [experience] install Visio on win11
- Graduation design game mall
- B站刘二大人-多元逻辑回归 Lecture 7
- How to download GB files from Google cloud hard disk
- C进阶-数据的存储(上)
- 嵌入式面试题(四、常见算法)
- Self built DNS server, the client opens the web page slowly, the solution
- YYGH-11-定时统计
- 04. Project blog log
- What is independent IP and how about independent IP host?
猜你喜欢
![[experience] install Visio on win11](/img/f5/42bd597340d0aed9bfd13620bb0885.png)
[experience] install Visio on win11

SequoiaDB湖仓一体分布式数据库2022.6月刊
[email protected]树莓派"/>[email protected]树莓派

02. Develop data storage of blog project

Notes, continuation, escape and other symbols

What is independent IP and how about independent IP host?

Sequoiadb Lake warehouse integrated distributed database, June 2022 issue

Fluent implements a loadingbutton with loading animation

ARTS Week 25

ArcGIS application foundation 4 thematic map making
随机推荐
Vulhub vulnerability recurrence 67_ Supervisor
【torch】|torch.nn.utils.clip_grad_norm_
SequoiaDB湖仓一体分布式数据库2022.6月刊
MySQL advanced learning summary 9: create index, delete index, descending index, and hide index
A master in the field of software architecture -- Reading Notes of the beauty of Architecture
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
Huawei od computer test question 2
Self built DNS server, the client opens the web page slowly, the solution
自建DNS服务器,客户端打开网页慢,解决办法
Qt TCP 分包粘包的解决方法
[experience] when ultralso makes a startup disk, there is an error: the disk / image capacity is too small
02. 开发博客项目之数据存储
[QNX Hypervisor 2.2用户手册]6.3.3 使用共享内存(shmem)虚拟设备
Questions d'examen écrit classiques du pointeur
B站刘二大人-多元逻辑回归 Lecture 7
01. Project introduction of blog development project
Jvxetable implant j-popup with slot
RustDesk 搭建一个自己的远程桌面中继服务器
Sequoiadb Lake warehouse integrated distributed database, June 2022 issue
通讯录管理系统链表实现