当前位置:网站首页>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
边栏推荐
- Plato Farm元宇宙IEO上线四大,链上交易颇高
- Question brushing plan - depth first search DFS (I)
- Preliminary analysis of Airbase
- [※ leetcode refers to offer 32 - II. Print binary tree II from top to bottom (simple)]
- Pytorch selects the first k maximum (minimum) values and their indexes in the data
- 2. Finishing huazi Mianjing -- 2
- 一文解决浏览器跨域问题
- Pipes and xargs
- IOT design and development
- [leetcode refers to the two numbers of offer 57. And S (simple)]
猜你喜欢

NVM introduction, NVM download, installation and use (node version management)

JS merge duplicate data in array object

ROS learning notes - tutorial on the use of ROS

管道和xargs

Ali has another "against the sky" container framework! This kubernetes advanced manual is too complete
![[leetcode refers to offer 18. Delete the node of the linked list (simple)]](/img/ee/1a546e2383948ad9a4ce69b4508e90.png)
[leetcode refers to offer 18. Delete the node of the linked list (simple)]

Tear the Google SRE book by hand

Database Experiment 7 stored procedure experiment

C#,打印漂亮的贝尔三角形(Bell Triangle)的源程序

随机推荐
阿里又一个“逆天”容器框架!这本Kubernetes进阶手册简直太全了
Unit function expansion
Deep understanding of modern mobile GPU (continuously updating)
Based on jsplumb JS to achieve multi list one to many connection effect
[leetcode refers to offer 27. Image of binary tree (simple)]
2.整理华子面经--2
Ali has another "against the sky" container framework! This kubernetes advanced manual is too complete
ROS learning notes - tutorial on the use of ROS
2022 - 04 - 24 Daily: Current Progress and Open Challenges of Applied Deep Learning in Biological Sciences
Yolov5 NMS source code understanding
This paper solves the cross domain problem of browser
管道和xargs
Keras. Layers introduction to various layers
Subcontracting of wechat applet based on uni app
C language programming based on loop structure (PTA)
Database Experiment 2 data query
Daily operation and maintenance knowledge -- 1
Tensorflow and pytorch middle note feature map size adjustment to achieve up sampling
1. Finishing huazi Mianjing -- 1
Pyuninstaller package exe cannot find the source code when running, function error oserror: could not get source code