728x90

https://harryp.tistory.com/630

 

[Linux] 우분투 터미널 다중 창, 창분할 - 터미네이터 (Terminator)

안녕하세요. 우분투를 개발 용도로 쓰다 보니 터미널이 분할이 되면 편할것 같아 다중 창 (창 분할)이 가능한 터미널을 찾다 발견한 프로그램을 소개합니다. 바로 터미네이터 (Terminator) 입니다.

harryp.tistory.com

 

728x90

'Terminal' 카테고리의 다른 글

scp 서버 파일 전송  (0) 2021.05.07
서버 재실행 : sudo reboot  (0) 2021.01.14
돌아가고 있는 processor 끄기  (0) 2020.11.04
주기적 실행 결과 표시  (0) 2019.10.10
파일 실행 권한없을때 (permission denied)  (0) 2019.08.24
728x90

https://www.slideshare.net/ssuser06e0c5/focal-loss-detection-classification

 

Focal loss의 응용(Detection & Classification)

One-stage Network(YOLO, SSD 등)의 문제점 예를 들어 근본적인 문제인 # of Hard positives(object) << # of Easy negatives(back ground) 또는 large object 와 small object 를 동시에 detect하…

www.slideshare.net

 

728x90

'Dic' 카테고리의 다른 글

Bayes optimal classifier  (0) 2021.01.04
Gaussian mixture model  (0) 2021.01.01
imagenet pretrained model에서 imagenet data 분포로 normalize하는 이유  (0) 2020.12.30
활성화 함수 nonlinear 이유  (0) 2020.12.14
resnet forward-hook  (0) 2020.11.20
728x90

imagenet pretrained model은

 

imagenet data 분포 값에 맞게 학습이 되어 있기 때문에,

 

imagenet pretrained 모델을 사용하는 경우 normalize 또한 imagenet data에 맞게 해주는 것이 좋다.

 

개념적으로는 우리가 사용하는 데이터가 imagenet dataset 분포에서 어느만큼 떨어져 위치하는지

 

보정해 준다고 생각하면 된다.

728x90

'Dic' 카테고리의 다른 글

Gaussian mixture model  (0) 2021.01.01
Focal Loss  (0) 2020.12.30
활성화 함수 nonlinear 이유  (0) 2020.12.14
resnet forward-hook  (0) 2020.11.20
deconvolution 차원 계산  (0) 2020.11.12
728x90

 

Paper

arxiv.org/abs/1912.02413

 

BBN: Bilateral-Branch Network with Cumulative Learning for Long-Tailed Visual Recognition

Our work focuses on tackling the challenging but natural visual recognition task of long-tailed data distribution (i.e., a few classes occupy most of the data, while most classes have rarely few samples). In the literature, class re-balancing strategies (e

arxiv.org

 

Code

github.com/Megvii-Nanjing/BBN

 

Megvii-Nanjing/BBN

The official PyTorch implementation of paper BBN: Bilateral-Branch Network with Cumulative Learning for Long-Tailed Visual Recognition - Megvii-Nanjing/BBN

github.com

 

 

Introduction

 

 

Imbalanced 문제는 주로 re-balancing 방법을 통해 접근하여 해결해왔다.

re-balancing

1. re-weighting

2. re-sampling

 

 

re-weighting 방법은 학습할 때, sample수가 적은 class의 경우 더 큰 weight를 통해 큰 loss값을 주고

sample수가 작은 class의 경우 저 작은 weight를 부여함으로 작은 loss값을 준다.

www.analyticsvidhya.com/blog/2020/10/improve-class-imbalance-class-weights/

 

How to Improve Class Imbalance using Class Weights in Machine Learning

Learn how to deal with imbalanced classes in machine learning by improving the class imbalance using Python.

www.analyticsvidhya.com

resampling 방법은 sample수가 적은 class에 대해서 sample을 추가적으로 생성하는 방법을 택한다.

가장 대표적인 방법이 SMOTE이다. (Synthetic Minority Oversampling TEchnique)

machinelearningmastery.com/smote-oversampling-for-imbalanced-classification/

 

SMOTE for Imbalanced Classification with Python

Imbalanced classification involves developing predictive models on classification datasets that have a severe class imbalance. The challenge of working with imbalanced datasets is that most machine learning techniques will ignore, and in turn have poor per

machinelearningmastery.com

SMOTE는 먼저 minority class에서 random으로 example을 select하고 그 example에 대해 k개의 nearest neighbor를 찾는다.

이때 새로 만들어지는 synthetic instance는 k nearest neighbor 에서 하나를 설정하고 (b), a와 b featrure를 linear combination하여 만들어낸다. 

 

 

 

하지만 이러한 re-balancing 접근 방법은 deep feature의 학습에서 영향을 받게 되고

결국 데이터 전체적으로 under fitting되는 단점이 존재한다.

 

본 논문에서는 re balancing 전략이 어떤 식으로 동작하는지를 살펴보고

deep network를 representation learning과 classifier learning 2가지로 나눠서 수행한다.

 

representation learning은 일단 일반적인 plain training을 의미한다고 보면 된다.

그리고 classifier learning은 representation learning 때 학습한 것을 paramater 고정시키고,

classifier만 'scratch'부터 새로 학습시킨다.

 

 

 

 

 

 

본 실험은 Representation learning과 Classifier learning을 각각 re-sampling방법과 Cross entropy 방법으로 나누어서

학습해본 결과이다. 실험결과 Representation learning은 re-sampling, Classifier learning은 Cross-entropy 방법을 사용하는 것이 좋다는 결과가 나왔다.

 

그래서 본 논문에서는 BBN 모델을 제안하며 , 이는 Representation learning과 classifirer learning을 따로 수행하는 형태의 learning방법을 의미한다.

 

 

이 모델은 2가지의 branch로 이루어져 있다.

 

1. Conventional learning branch

 

원래 long-tail distribution pattern을 그대로 학습하는 용도로 사용된다. (typical uniform sampler 사용)

 

2. Re-balancing branch 

 

Re-Balancing Sampler는 tail 쪽 data를 좀더 많이 sampling한다.

 

이때, a는 Adaptor에 의해 생성되고 , universal feature에서 tail data에 대한 feature를 learning하도록 

조절하는 역할을 한다. 

 

그리고 a는 각 branch의 parameter를 update하는 control하는 용도로도 사용된다. 

 

 

 

그러면 re-balancing 방법은 어떻게 동작하는 것일까?

deep network는 feature extractor part와  classifier part로 나뉜다.

class re-balancing straregies는 train data distribution을 test data distribution\

의 형태로 바꿔주어서 classification 성능을 향상시킬 수는 있다.

 

그러나 이러한 방식에 대해 본 논문에서는 가설을 하나 제기한다.

이러한 방법은 classifier learning의 성능은 향상시키지만

universal representative ability 에는 성능을 저하시키는 영향을 준다.

 

 

위의 그림을 다시 살펴보자.

 

Representation learning 방법을 하나로 고정시킨채로 살펴보면

Classifier learning을 CE로 하는 것 보다 RW, RS 형태로 하는 것이 더 성능이 좋은 것을 확인할 수 있다.

이는 classifier weight를 조정하는 re-balancing operation이 test distribution에 적합하여 더 좋은 성능을 내는 것이다.

 

이와 다르게 Classifier learning 방법을 하나로 고정시킨채 살펴보면

Representation learning의 경우 CE로 했을때 가장 좋은 성능을 보임을 알 수 있다.

즉 discriminative한 deep feature을 학습하는 것에는 RW/RS한 방법이 좋지 않음을 확인할 수 있다.

 

 

 

그래서 본 논문에서는 아래와 같은 framework를 만들고 실제로 적용한다. 

 

 

 

logit은 아래와 같이 weighting한다.

 

이때 a는 다음과 같은 수식으로 정의되며,  T_max는 최대 epoch, T는 현재 epoch으로 정의된다.

 

 

 

uniform sampler

 

uniform sampler는 data distribution의 형태 그대로 sampling 하기 때문에, 

data가 많은 many class에 대한 학습이 더 많이 진행되게 되고 따라서 feature의 학습 즉,

representation learning이 더욱 잘 되게 된다.

 

re-balancing branch

 

이와 다르게 rebalancing branch는 extreme한 imbalance를 해결하기 위한 것으로

tail class에 대한 classification accuracy를 상승시키기 위한 것이다.

 

Code

 

 

실제 코드 구성은 위와 같다. 

uniform sampler로 부터 sampling한 image_a

rebalancing sampler로 부터 sampling한 image_b

 

두개의 image를 각각 conventional branch와 rebalancing branch에 입력으로 사용하고

feature_a, feature_b를 추출한다.

 

이를 통해서 논문의 내용대로 a값을 이용해 이를 조합하고,

loss 또한 image 두개의 label을 이용해 조합하여 loss값을 준다. (mix_up 형태)

 

Inference Phase

 

Inference 단계에서는 같은 sample이 두개의 branch에 입력으로 들어가게 되며,

a는 0.5를 적용한다. 

 

 

Data sampler - detailed with code

Data sample을 위한 각 클래스간의 sampling 확률 도출 방법은 다음과 같다.

(밑의 식은 reversed sampling)

 

 

 

Visualization of classfier weights

 

classifier의 weight의  l-2 norm의 크기는 classifier의 preference를 의미한다.

(www.microsoft.com/en-us/research/wp-content/uploads/2017/07/one-shot-face.pdf)

 

그렇기 때문에 class별 weight의 l_2의 분포값이 작을수록 balance에 맞게 학습된 것을 의미한다.

 

BNN-CB의 경우 conventional branch를 의미하며, original dataset에 대해서 학습된 것처럼,

majority class에 더 높은 preference를 가지는 것을 확인할 수 있다.

 

BNN-RB의 경우 reblanced branch를 의미하며, rebalanced distribution에 대해서 학습된 것처럼,

minority class에 더 높은 preference를 가지는 것을 확인할 수 있다.

 

이 2개를 합친 BNN_ALL의 경우 std가 가장 작은 것을 볼 수 있다.

 

즉 class에 대한 preference가 골고루 퍼져있음을 알 수 있다.

 

Conclusion

이 논문은 다음과 같은 장점을 노렸다고 생각한다.

original data로 부터 feature learning의 장점을 얻기 위해 

Conventional branch를 통해서 original distribution에 대해 학습을 진행한다.

 

이를통해서 backbone네트워크는 좀더 좋은 feature를 학습하게 된다.

 

이전 실험이 먼저 representation learning을 한 이후에 classifier learning를 RW, RS 형태로 진행한 것 처럼

알파(a) 값을 조정하여 처음에는 uniform sampler로 부터 학습을 시작하고, 이로부터 feature가 잘 학습된 backbone 네트워크로부터 RS/RW 효과를 내는 re-balancing branch로 부터 학습을 늘린다. 

 

mix-up형태를 사용한 이유는 어찌되었든, conventional learning branch는  최종적으로 W_c가 majority class에 preference를 더 가지도록 학습이 된다. 그리고 Re-Balancing Branch는 W_r이 Minority class에 preference를 가지도록 학습이 된다. 그러나 mix-up형태를 취함으로서 이러한 편향을 balance한 형태로 맞추어 줄 수 있다고 생각되어 진다.

 

 

 

 

728x90
728x90

wikidocs.net/24987

 

위키독스

온라인 책을 제작 공유하는 플랫폼 서비스

wikidocs.net

 

728x90

'Dic' 카테고리의 다른 글

Focal Loss  (0) 2020.12.30
imagenet pretrained model에서 imagenet data 분포로 normalize하는 이유  (0) 2020.12.30
resnet forward-hook  (0) 2020.11.20
deconvolution 차원 계산  (0) 2020.11.12
pretext task  (0) 2020.11.04
728x90

web.stanford.edu/~nanbhas/blog/forward-hook.html

 

Intermediate Activations — the forward hook

How do you get intermediate activations from a PyTorch model?

web.stanford.edu

 

728x90

'Dic' 카테고리의 다른 글

imagenet pretrained model에서 imagenet data 분포로 normalize하는 이유  (0) 2020.12.30
활성화 함수 nonlinear 이유  (0) 2020.12.14
deconvolution 차원 계산  (0) 2020.11.12
pretext task  (0) 2020.11.04
JSON  (0) 2020.10.26
728x90

jangjy.tistory.com/310

 

Deconvolution 파라미터에 따른 출력 크기 계산하기

deconvolution의 경우 잘 사용하지 않는 개념이라 가끔 출력단의 크기를 계산할때 햇갈리더라. 생각해보면 convolution의 역 연산이기 떄문에 convolution 출력 크기 공식을 역으로 계산하면 간단한 문제

jangjy.tistory.com

 

728x90

'Dic' 카테고리의 다른 글

활성화 함수 nonlinear 이유  (0) 2020.12.14
resnet forward-hook  (0) 2020.11.20
pretext task  (0) 2020.11.04
JSON  (0) 2020.10.26
graph centrality  (0) 2020.10.10
728x90

stats.stackexchange.com/questions/404602/pretext-task-in-computer-vision

 

Pretext Task in Computer Vision

I am new to Computer Vision. I am reading many papers and i see the term "pretext task". Can anyone explain what exactly it means. Thanks in Advance.

stats.stackexchange.com

 

728x90

'Dic' 카테고리의 다른 글

resnet forward-hook  (0) 2020.11.20
deconvolution 차원 계산  (0) 2020.11.12
JSON  (0) 2020.10.26
graph centrality  (0) 2020.10.10
Spectral Clustering Algorithm Implemented From Scratch  (0) 2020.10.04

+ Recent posts