로딩
요청 처리 중입니다...

소프트맥스회귀_구현하기

 소프트맥스회귀_구현하기

import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim torch.manual_seed(1) x_train = [[1, 2, 1, 1], [2, 1, 3, 2], [3, 1, 3, 4], [4, 1, 5, 5], [1, 7, 5, 5], [1, 2, 5, 6], [1, 6, 6, 6], [1, 7, 7, 7]] y_train = [2, 2, 2, 1, 1, 1, 0, 0] x_train = torch.FloatTensor(x_train) y_train = torch.LongTensor(y_train) print(x_train.shape) print(y_train.shape) torch.Size([8, 4]) torch.Size([8]) y_one_hot = torch.zeros(8, 3) y_one_hot.scatter_(1, y_train.unsqueeze(1), 1)...