TNT 스터디 2주차 몰랐던 것(1)

2021. 9. 17. 16:09전공공부/전자전기전공

1. LIME & Attention

LIME에 관한 간단한 설명

LIME과 관련한 스터디를 진행한 뒤, Attention이라는 새로운 method도 알게 되었다. 둘 다 모두 인간에게 NLP나 CNN이 어떻게 작동되는지 직관적인 뷰를 제공하는 툴이다. 즉 인공지능이 그렇게 판단한 이유를 보기 쉽게 설명한 다는 것이다.

Attention 예시

위의 사진을 보면 I love you를 je t' aime로 통역한 이유를 알 수 있다. 진하게 표시한 부분이 가중치를 더 많이 준 것을 알 수 있다. 앞으로 task에서 많이 활용할 예정이다.

 

2. 데이터셋 뻘짓

데이터 모델에서 fft를 활용하려고 scipy.fftpack.fft()를 활용하려고 하였다. 하지만 이미 데이터셋 함수에서 from_tensor_slices를 활용해서 tensor로 변환한 이후였다. numpy로 바꾸려고 많은 방법을 사용했지만 작동이 되지 않았다. 에러로 no attribute property 라고 나올 뿐이다.

스터디에서 질문한 결과 tensor를 활용한 모델을 만들 때는 항상 tf 함수를 사용하라고 한다. tf.signal.fft를 이용하면 잘 활용 가능하다. 항상 tf함수에서 고려해야 겠다. 

 

3. MCdropout 몬테카를로 dropout

 

What is Monte Carlo dropout?

I understand how to use MC dropout from this answer, but I don't understand how MC dropout works, what its purpose is, and how it differs from normal dropout.

datascience.stackexchange.com

 

 

Monte Carlo Dropout

Improve your neural network for free with one small trick, getting model uncertainty estimate as a bonus.

towardsdatascience.com

Dropout은 기본적으로 정규화과정을 통해 overfitting을 방지하는 목적을 가진다. 하지만 normal한 dropout은 test과정에서 deterministic하다. 같은 dropout ratio를 주면 언제나 같은 결과가 나온다. 하지만 montecarlo dropout은 train, test과정에서 모두 발현되기 되고 node/link를 랜덤하게 끈다. 그래서 랜덤한 결과가 나온다. 

 

실제로 코딩하는 방법은 두번째 레퍼런스에 나와있다.

 

4. keras.layers.GRU vs LSTM

 

Illustrated Guide to LSTM’s and GRU’s: A step by step explanation

Hi and welcome to an Illustrated Guide to Long Short-Term Memory (LSTM) and Gated Recurrent Units (GRU). I’m Michael, and I’m a Machine…

towardsdatascience.com

GRU와 LSTM은 둘다 RNN의 vanishing gradient 문제를 없애기 위한 등장한 모델이다. long sequence에서 이 문제가 등장하는데, 이 두 모델은 중요하지 않은 정보를 잊어버리고, 중요한 정보를 기억하는 역할을 한다. 

GRU는 2개의 게이트로, LSTM은 3개의 게이트로 정보를 처리한다. 그렇다보니 연산효율 부분에서 GRU가 성능이 좋다고 한다. 하지만 많은 데이터를 활용할때는 LSTM이 효과적이라고 한다.

 

When to use GRU over LSTM?

The key difference between a GRU and an LSTM is that a GRU has two gates (reset and update gates) whereas an LSTM has three gates (namely input, output and forget gates). Why do we make use of GR...

datascience.stackexchange.com