绘制Loss曲线
b站课程链接:https://www.bilibili.com/video/BV1Y7411d7Ys?p=2
import绘制曲线的库和numpy库
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
定义Loss函数
def loss(x, y):
y_pred = forward(x)
return (y_pred
2021-12-30 15:40:57
60KB
c
OR
oss
1