__author__ = 'SherlockLiao'
import torch
from torch import nn, optim
from torch.autograd import Variable
import numpy as np
import matplotlib.pyplot as plt
x_train = np.array([[3.3], [4.4], [5.5], [6.71], [6.93], [4.168],
[9.779], [6.182], [7.59], [2.167], [7.042],
[10.791], [5.313], [7.997], [3.1]], dtype=np.float32)
y_train = np.array([[1.7], [2.76], [2.09], [3.19], [1.694], [1.573],
[3.366], [2.596], [2.53], [1.221], [2.827],
[3.465], [1.65], [2.904], [1.3]], dtype=np.float32)
x_train = torch.from_numpy(x_train)
y_train = torch.from_numpy(y_train)
# Linear Regression Model
class LinearRegression(nn.Module):
def __init__(self):
super(LinearRegression, self).__init_
Pytorch 入门之--线性回归 Linear_Regression Pytorch 实现
最新推荐文章于 2024-09-19 11:10:49 发布
本文将引导读者入门PyTorch,通过实例详细解释如何使用PyTorch实现线性回归模型。内容涵盖线性回归的基本概念,以及如何构建、训练和评估模型。
摘要由CSDN通过智能技术生成