class ResNet(nn.Module): def __init__(self, num_classes): super(ResNet, self).__init__() self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3) self.bn1 = nn.BatchNorm2d(64) self.relu = nn.ReLU(inplac
resnet_model.py import torch.nn as nn import torch class BasicBlock(nn.Module): expansion = 1 def __init__(self, in_channel, out_channel, stride=1, downsample=None): super(BasicBlock, self).__init__() self.conv1 = nn.Conv2d(in_channels=in_channel, out_channels=out_channel, kern...
max_train_size = np.max([ len(dataset_train[dname]) for dname in datasets]) dataset_train[d].image_paths = dataset_train[d].image_paths*int(np.ceil(float(max_train_size)/len(dataset_train[d].image_paths))) dataset_train[d].label_paths = dataset_train[d].label_paths*int(np.ceil...
class MixUpAugmentationLoss(nn.Module): def __init__(self, criterion): super().__init__() self.criterion = criterion def forward(self, input, target, *args): # Validation step if isinstance(target, torch.Tensor): return self.criterion(input, target, *args) target_a, target_b, lmbd ...