We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1dConv를 사용하여 구축한 모델 공유합니다 :)
class DeepConv(nn.Module): def __init__(self, args): super(DeepConv, self).__init__() self.args = args self.device = args.device self.hidden_dim = self.args.hidden_dim # categorical features # ========================== nn.Embedding에 들어갈 self.embedding_dims의 개수를 수정해주세요 =============================== self.in_channels = self.args.n_cates + self.args.n_conts # ========================================================================================================================= self.conv1 = nn.Sequential( nn.Conv1d(in_channels=self.in_channels, out_channels=self.hidden_dim, kernel_size=3, padding=1, padding_mode='zeros'), nn.BatchNorm1d(self.hidden_dim), nn.ReLU() ) self.avg_pool = nn.AvgPool1d(kernel_size=2) self.conv2 = nn.Sequential( nn.Conv1d(in_channels=self.hidden_dim//2, out_channels=self.hidden_dim, kernel_size=3, padding=1, padding_mode='zeros'), nn.BatchNorm1d(self.hidden_dim), nn.ReLU() ) self.conv3 = nn.Sequential( nn.Conv1d(in_channels=self.hidden_dim, out_channels=self.hidden_dim, kernel_size=3, padding=1, padding_mode='zeros'), nn.BatchNorm1d(self.hidden_dim), nn.ReLU() ) self.conv4 = nn.Sequential( nn.Conv1d(in_channels=self.hidden_dim, out_channels=self.hidden_dim, kernel_size=3, padding=1, padding_mode='zeros'), nn.BatchNorm1d(self.hidden_dim), nn.ReLU() ) self.max_pool = nn.MaxPool1d(kernel_size=2) # Fully connected layer self.fc = nn.Linear(self.hidden_dim//2, 1) self.activation = nn.Sigmoid() def forward(self, input): categorical, continuous, mask, __ = input batch_size = categorical[0].size(0) seq_len = categorical[0].size(1) # concat Catgegorical & Continuous Feature x_cat = torch.stack(categorical) # [17, 128, 250] x_cont = torch.stack(continuous) # [3, 128, 250] embed = torch.cat([x_cat, x_cont], 0) # [20, 128, 250] embed = embed.permute(1, 0, 2) # [128, 20, 250] conv1_output = self.conv1(embed.type(torch.FloatTensor).to(self.device)) conv1_output = conv1_output.permute(0, 2, 1) avg_output = self.avg_pool(conv1_output) avg_output = avg_output.permute(0, 2, 1) conv2_output = self.conv2(avg_output) conv3_output = self.conv3(conv2_output) conv4_output = self.conv3(conv3_output) res = conv2_output + conv4_output res = res.permute(0, 2, 1) max_output = self.max_pool(res) out = self.fc(max_output) pred = self.activation(out).view(batch_size, -1) return pred
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1dConv를 사용하여 구축한 모델 공유합니다 :)
The text was updated successfully, but these errors were encountered: