def __init__(self): super(ResNet18, self).__init__() self.block1 = nn.Sequential( nn.Conv2d(channel_size, hidden_size, kernel_size=2, stride=2, padding=3, bias=False), nn.BatchNorm2d(hidden_size), nn.ReLU(True)) self.block2 = nn.Sequential(nn.MaxPool2d(1, 1), ResidualBlock(hidden_size, hidden_size), ResidualBlock(hidden_size, hidden_size, 2)) self.block3 = nn.Sequential( ResidualBlock(hidden_size, hidden_size * 2), ResidualBlock(hidden_size * 2, hidden_size * 2, 2)) self.block4 = nn.Sequential( ResidualBlock(hidden_size * 2, hidden_size * 4), ResidualBlock(hidden_size * 4, hidden_size * 4, 2)) self.block5 = nn.Sequential( ResidualBlock(hidden_size * 4, hidden_size * 8), ResidualBlock(hidden_size * 8, hidden_size * 8, 2)) self.avgpool = nn.AvgPool2d(2) self.fc = nn.Linear(512 * 4, 512) # vowel_diacritic self.fc1 = nn.Linear(512, 11) # grapheme_root self.fc2 = nn.Linear(512, 168) # consonant_diacritic self.fc3 = nn.Linear(512, 7)
def __init__(self): super(ResNet18, self).__init__() self.block1 = nn.Sequential( nn.Conv2d(channel_size, hidden_size, kernel_size=2, stride=2, padding=3, bias=False), nn.BatchNorm2d(hidden_size), nn.ReLU(True)) self.block2 = nn.Sequential(nn.MaxPool2d(1, 1), ResidualBlock(hidden_size, hidden_size), ResidualBlock(hidden_size, hidden_size, 2)) self.block3 = nn.Sequential( ResidualBlock(hidden_size, hidden_size * 2), ResidualBlock(hidden_size * 2, hidden_size * 2, 2)) self.block4 = nn.Sequential( ResidualBlock(hidden_size * 2, hidden_size * 4), ResidualBlock(hidden_size * 4, hidden_size * 4, 2)) self.block5 = nn.Sequential( ResidualBlock(hidden_size * 4, hidden_size * 8), ResidualBlock(hidden_size * 8, hidden_size * 8, 2)) self.avgpool = nn.AvgPool2d(2) self.custom_fc = nn.Sequential( nn.BatchNorm1d(2048, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True), nn.Dropout(p=0.25), nn.Linear(in_features=2048, out_features=2048, bias=True), nn.ReLU(inplace=True), nn.BatchNorm1d(2048, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True), nn.Dropout(p=0.5), nn.Linear(in_features=2048, out_features=512, bias=True), ) # vowel_diacritic self.fc1 = nn.Linear(512, 11) # grapheme_root self.fc2 = nn.Linear(512, 168) # consonant_diacritic self.fc3 = nn.Linear(512, 7)