Week7 Day1

📋 ImageImage classificationclassification

📌 classifierclassifier

  • A mapping f( ) that maps an image to a category level

📌 KK NearestNearest NeighborsNeighbors (KNN)(KNN)

  • classifies a query data point according to reference points closest to the query

📌 NeuralNeural NetworkNetwork

  • compress all the data we have into the neural network
  • takes every pixel of an image as input
  • Is this model suitable for solving the image classification problem?

📌 ConvolutionalConvolutional NeuralNeural NetworkNetwork

  • Convolutional neural networks are locally connected neural networks
  • Local feature learning / Parameter sharing

📌 AlexNetAlexNet

  • 7 hidden layer
  • Using better activation function (ReLU)
  • regularization technique (Dropout)

📌 DropDrop outout

  • 지나치게 학습 집중하여 overfitting되는 문제를 해결하기 위한 방법
  • 각 미니배치 학습마다 네트워크 일부를 생략하여 학습하고 최종적으로 모델의 결합으로 학습 일반화 효과를 얻는다.
  • 같은 데이터로 여러 개의 서로 다른 모델을 훈련한 뒤 그 결과를 다수결 등으로 종합해 보면 통계적으로 덜 '튀는' 결과
  • 비슷한 위치에 있는 퍼셉트론은 비슷한 특징에 집중해 버리는 상호 동조(co-adaptation)를 예방하는 의미

📌 VGGNetVGGNet

  • deeper architecher
  • only 3x3 conv filter block / 2x2 maxpooling

  • 필터 사이즈를 줄이면서 파라미터 수 적게 여러층 쌓을 수 있게되었다.

📋 AnnotationAnnotation datadata efficientefficient learninglearning

📌 DataData AugmentationAugmentation

  • training data set contains only fractional part of real data
  • Augmenting data to fill more space and to close the gap
  • Brightness adjustment / Rotate / flip / Crop / Affine transform

📌 CutMixCutMix

  • regional dropout 방법이 효과적이나 정보손실을 유발한다 이를 보완하는 방법
  • data augmentation 방법으로 이미지의 일부분을 다른 이미지에서 따온 patch로 대체 그 후 patch의 비율에 따라 label조정

  • cutmix 여부, 어떤 image를 믹스 할지, 어느 위치를 믹스할지 랜덤하게 정한다
for i, (input, target) in enumerate(train_loader):
    
        input = input.cuda()
        target = target.cuda()

        r = np.random.rand(1)
        if args.beta > 0 and r < args.cutmix_prob:
            # generate mixed sample
            lam = np.random.beta(args.beta, args.beta)
            rand_index = torch.randperm(input.size()[0]).cuda()
            target_a = target
            target_b = target[rand_index]
            bbx1, bby1, bbx2, bby2 = rand_bbox(input.size(), lam)
            input[:, :, bbx1:bbx2, bby1:bby2] = input[rand_index, :, bbx1:bbx2, bby1:bby2]
            # adjust lambda to exactly match pixel ratio
            lam = 1 - ((bbx2 - bbx1) * (bby2 - bby1) / (input.size()[-1] * input.size()[-2]))
            # compute output
            output = model(input)
            loss = criterion(output, target_a) * lam + criterion(output, target_b) * (1. - lam)
        else:
            # compute output
            output = model(input)
            loss = criterion(output, target)

📌 TransferTransfer LearingLearing

  • similar datasets share common information
  • adapt to a new task by leveraging pre-trained knowledge
model = vgg11(pretrained = True)
model.classifier[6] = nn.Linear(in_features=4096, out_features=7, bias=True)
model.cuda()

# Freeze the feature extracting convolution layers
for param in model.features.parameters():
    param.requires_grad = False

📌KnowledgeKnowledge DistillationDistillation

  • Passing what model learned to ‘another’ smaller model (compression)
  • pseudo-labeling (Generating pseudo-labels for an unlabeled dataset)
  • 실제 label에 대해서는 hard label사용, sudo label에 대해서는 soft label을 사용
  • temperature를 통해서 아웃풋 사이의 큰값과 작은값의 차이를 줄여준다
def train(self, epoch):

        T = 2
        self.model.cuda()
        self.model.train()

        lamb = 0.9

        for data, target in tqdm(self.train_data_iterator):
            data, target = data.cuda(), target.long().cuda()

            output = self.model(data)

            loss_CE = self.loss(output, target)

            score = self.model_teacher(data).data
            soft_target = F.softmax(score/T, dim=1)
            output_smooth = F.log_softmax(output/T, dim=1)
            loss_KD = F.kl_div(output_smooth, soft_target, reduction='batchmean')

            self.optimizer.zero_grad()

            (lamb * loss_pre_KD + (1 - lamb) * loss_CE).backward()
            self.optimizer.step()

📌 SelfSelf-TrainingTraining

  • Augmentation+Teacher-Studentnetworks+semi-supervisedlearning

좋은 웹페이지 즐겨찾기