天才一秒记住【长江书屋】地址:https://www.cjshuwu.com
self.fc=nn.Linear(24*2*2,2)
defforward(self,x):
batchsize=x.size(0)
out=selfonv1(x)
out=self.max_pooling1(out)
out=selfonv2_1(out)
out=selfonv2_2(out)
out=self.max_pooling2(out)
out=out.view(batchsize,-1)
out=self.fc(out)
out=F.log_softmax(out,dim=1)
returnout
classTrainingDataSet(Dataset):
def__init__(self):
super(TrainingDataSet,self).__init__()
self.data_dict_X=X_train
self.data_dict_y=y_train
def__getitem__(self,index):
t=self.data_dict_X[index,0:36]
t=torch.tensor(t).view(6,6)
returnt,self.data_dict_y[index]
def__len__(self):
returnlen(self.data_dict_y)
classTestDataSet(Dataset):
def__init__(self):
super(TestDataSet,self).__init__()
self.data_dict_X=X_validate
self.data_dict_y=y_validate
def__getitem__(self,index):
t=self.data_dict_X[index,0:36]
t=torch.tensor(t).view(6,6)
returnt,self.data_dict_y[index]
def__len__(self):
returnlen(self.data_dict_y)
defcnn_classification():
batch_size=256
trainDataLoader=DataLoader(TrainingDataSet(),batch_size=batch_size,shuffle=False)
本章未完,请点击下一章继续阅读!若浏览器显示没有新章节了,请尝试点击右上角↗️或右下角↘️的菜单,退出阅读模式即可,谢谢!