当前位置:网站首页>Pytorch deep learning practice (2)
Pytorch deep learning practice (2)
2022-04-23 21:59:00 【Know what you know and slowly understand what you don't know】
B standing Lord Liu
2. Linear model
#liu Linear model
import numpy as np
import matplotlib.pyplot as plt
x_data=[1.0,2.0,3.0]
y_data=[2.0,4.0,6.0]
def forward(x):
return x*w
def loss(x,y):
y_pred=forward(x)
return (y_pred-y)*(y_pred-y)
w_list=[]
mse_list=[]
for w in np.arange(0.0,4.1,0.1):
print('w',w)
l_sum=0
for x_val,y_val in zip(x_data,y_data):
y_pred_val=forward(x_val)
loss_val=loss(x_val,y_val)
l_sum+=loss_val
print('\t',x_val,y_val,y_pred_val,loss_val)
print('MSE=',l_sum/3)
w_list.append(w)
mse_list.append(l_sum/3)
plt.plot(w_list,mse_list)
plt.ylabel('loss')
plt.xlabel('w')
plt.show()
版权声明
本文为[Know what you know and slowly understand what you don't know]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204200609332826.html
边栏推荐
- flomo软件推荐
- Tensorflow realizes gradient accumulation, and then returns
- Assertionerror: invalid device ID and runtimeerror: CUDA error: invalid device ordinal
- ROS learning notes - tutorial on the use of ROS
- Presto on spark supports 3.1.3 records
- Lightweight project management ideas
- A series of problems of C DataGridView binding list
- Normalized transforms in pytorch The real calculation process of normalize
- [leetcode refers to offer 22. The penultimate node in the linked list (simple)]
- 从严从重从快 上海全面加强疫情期间食品安全监管
猜你喜欢
Pycharm Chinese plug-in
Google tries to use rust in Chrome
C# ftpHelper
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ‘:app:stripDe
Yolov5 NMS source code understanding
Mixed use of Oracle column row conversion and comma truncated string
C language programming based on loop structure (PTA)
轻量化项目管理思路
Lightweight project management ideas
[leetcode refers to offer 42. Maximum sum of continuous subarrays (simple)]
随机推荐
Daily operation and maintenance knowledge -- 1
Detailed explanation of basic assembly instructions of x86 architecture
Error message: b04access.00f eve'. Read of address 000001B4
C list data paging
1.整理华子面经--1
清华大学 | WebFace260M:百万级深度人脸识别的基准(TPAMI2022)
[leetcode refers to offer 21. Adjust the array order so that odd numbers precede even numbers (simple)]
Pyuninstaller package exe cannot find the source code when running, function error oserror: could not get source code
Problem brushing plan -- dynamic programming (III)
April 24, 2022 Daily: current progress and open challenges of applying deep learning in the field of Bioscience
Crisis is opportunity. Why will the efficiency of telecommuting improve?
[leetcode refers to offer 10 - I. Fibonacci sequence (simple)]
Yolov5 NMS source code understanding
[leetcode refers to offer 22. The penultimate node in the linked list (simple)]
The DNN of OpenCV is used to read onnx as the prediction end to realize classification
Idea import a project
A method of asynchronous response of application service through load balancing
C#,打印漂亮的贝尔三角形(Bell Triangle)的源程序
Two Stage Detection
[※ leetcode refers to offer 32 - II. Print binary tree II from top to bottom (simple)]