File size: 849 Bytes
ff282f7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import torch
import torch.nn as nn
import torch.nn.functional as F
import pickle
# SimpleClassifier ํด๋์ค ์ ์
class SimpleClassifier(nn.Module):
def __init__(self, input_size, num_classes):
super(SimpleClassifier, self).__init__()
self.fc1 = nn.Linear(input_size, 256)
self.fc2 = nn.Linear(256, 128)
self.fc3 = nn.Linear(128, num_classes)
self.dropout = nn.Dropout(0.3)
def forward(self, x):
x = F.relu(self.fc1(x))
x = self.dropout(x)
x = F.relu(self.fc2(x))
x = self.dropout(x)
x = self.fc3(x)
return x
# ๋ชจ๋ธ ํ์ผ ๋ค์ ์์ฑ
with open('semantic_model.pkl', 'rb') as f:
data = pickle.load(f)
torch.save(data['model'].state_dict(), 'pytorch_model.bin')
print("๋ชจ๋ธ ํ์ผ ์ฌ์์ฑ ์๋ฃ!")
|