Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ch3] QnA #5

Open
SooDevv opened this issue Jul 5, 2019 · 3 comments
Open

[Ch3] QnA #5

SooDevv opened this issue Jul 5, 2019 · 3 comments

Comments

@SooDevv
Copy link

SooDevv commented Jul 5, 2019

No description provided.

@SooDevv SooDevv changed the title [ch3] QnA [Ch3] QnA Jul 7, 2019
@SooDevv
Copy link
Author

SooDevv commented Jul 7, 2019

p146에서 질문있습니다.

3.5.3 통계 기반 vs 추론 기반에서 어휘에 추가할 새 단어가 생겨서 단어의 분산 표현을 갱신해야 하는 상황을 생각해봅시다. 이 문단에서 질문이 있는데요.

통계 기반 기법은 일괄 처리이기 때문에 새로운 단어가 들어오면 다시 통째로 학습해야하고, 추론 기반 기법은 mini_batch단위로 갱신하기 때문에 기존에 학습한 모델의 가중치 자체를 초기값으로 사용하여 새로운 단어를 모델.fit 시키면된다고 이해했습니다.

워드 임베딩을 할 때, SVD를 이용한 PCA를 사용하면 새로운 단어가 들어왔을 때 일괄처리를 해야되는 게 맞는데(통계기반), IPCA(Incremental PCA)로 했을 때는 위의 추론 기반 기법과 일맥상통할까요?
참고로 IPCA는 mini batch단위로 PCA를 합니다. (메모리이슈)

inc_pca = IncrementalPCA(n_components=차원수)
for mini_batch in np.array_split(X, batch_size):
    inc_pca.partial_fit(mini_batch)
word_representation = inc_pca.transform(X)

요 코드에서 새로운 단어가 왔을 때 갱신하고자 한다면 inc_pca.partial_fit(new_word) 로 하면 되는건지? 궁금합니다

@diemori
Copy link
Contributor

diemori commented Jul 9, 2019

저도 이 부분에 대해서는 조금 더 확인이 필요하지만, 제가 이해하기로는 word2vec과 같은 신경망 학습과 IPCA는 같은 장점을 공유하지만 일맥상통한다고 보기는 어려울 것 같습니다.

추론 기반 word2vec은 말씀하신대로 가중치를 갱신하는 방식을 기본으로 하고, IPCA는 실제로 sklearn 코드를 보면 fit() 함수 내에서도 전체 batch를 mini_batch_size로 잘라서 partial_fit()을 반복 호출 하고 있습니다.

이 방식을 최초로 제안한 논문을 못 찾아서 sklearn 코드를 보면서 추측한거라 확실할지는 모르겠네요.^^;
https://github.com/scikit-learn/scikit-learn/blob/7813f7efb/sklearn/decomposition/incremental_pca.py#L15

@SooDevv
Copy link
Author

SooDevv commented Jul 9, 2019

After training a scikit-learn model, it is desirable to have a way to persist the model for future use without having to retrain.
-> Model persistence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants