Regression
就我现在学到的知识而言,我所目前知道的问题分两类,一类是回归分析,另一类是分类。
初学者水平较低,仅为个人学习笔记,如有纰漏,请大佬们指出~
今天所学的就是回归 Regression。1.搭建神经网络 2.定义损失函数 3.训练网络
先贴出代码
import torch
import torch.nn.functional as F #import activation fuctions(导入激活函数)
class Net(torch.nn.Module): # extends the module of torch(继承torch中的 Module 模块)
def __init__(self,n_input,n_hidden1,n_hidden2,n_output):
super(Net,self).__init__() # extends the init fuctions(继承初始化方法)
self.hidden1 = torch.nn.Linear(n_input,n_hidden1)# linear function (线性函数)
self.hidden2 = torch.nn.Linear(n_hidden1,n_hidden2)#linear function(线性函数)
self.output = torch.nn.Linear(n_hidden2,n_output)#linear function(线性函数)
def forward(self,x):# forward function (前向传播方法)