| 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("๋ชจ๋ธ ํ์ผ ์ฌ์์ฑ ์๋ฃ!") | |