import torch
import torch.nn as nn
import torchvision.datasets as dsets
import torchvision.transforms as transforms
from torch.autograd import Variable
from torch.nn import Linear
import scipy
import numpy as np
import matplotlib.pyplot as plt
class myFirstNetwork(nn.Module):
def __ini__(self,input_size,hidden_size,output_size):
super(myFirstNetwork,self).__init__()
self.layer1 = nn.Linear(input_size,hidden_size)
self.layer2 = nn.Linear(hidden_size,output_size)
def __forward(self,input):
out = self.layer1(input)
out = nn.ReLU(out)
out = self.layer2(out)
return out
# super方法用于将子类的参数传给父类,例子中的父类是nn.Module
# ini方法相当于python中的构造器