Review: SPE
spe 학습 경과등을 기록한다.
rdkit
m.GetNumAtoms()
는 spe의 원자토큰화기에서 (,=,#
같은 문자 제거한 후의 갯수.
np.random.shuffle()
얼마나 랜덤한지? 개선 필요한지?
MolToSmiles(nm1,canonical=False, isomericSmiles=True, kekuleSmiles=False)
셋중 하나만 하면 오리지날과 같음. 2개부터 오리지널과 다름. (당연히)
변한모습도 3개가 가장 다름.
learn_spe
중 sorted(vocab.items(), key=lambda x: x[1], reverse=True)
는 get_vocabulary
써서 얻은 결과 (딕셔너리꼴)
에
- ascii오름차순정렬
- 람다로 횟수 오름차순정렬로 바꿈
- reverse함
결론:
sorted(vocab.items(), key=lambda x: x[1], reverse=True)
는횟수 역순(내림차순)
dataset
- deepchem 라이브러리에서 chembl다운주소잇엇음 문서참고 걔량 내 .smi무슨차이잇나 확인
learner.py
def corpus_augment(infile, outdir, cycles):
with open(f'{outdir}/{fname}_R{i}.{ftype}', 'a') as outfile:
def learn_SPE(infile, outfile, num_symbols, min_frequency=2, augmentation=0, verbose=False, total_symbols=False):
SMILES 갯수 파악:
- 앞서 전처리기에서 쪼개놓은 토큰 시리즈를 사용해서 연속된 문자쌍 (character_i)와 (character_i+1)의
(출현)
횟수를 세고 내림차순으로 순위를 매긴다.
로컬머신에서 2시간이상 그마저도 커널 리스타트되서 실행못했던 것을 colab 으로 24분걸림(learning spe, dataset=chembl25 augmentation=0,)
colab+conda = condacolab pip로 설치
그러나 chembl25+augmentation(=1)
한것 357만개(2*1.7M)
가량 코랩도 페어 얻기 시에 학습 에러발생.
Subword is in between word and character. It is not too fine-grained while able to handle unseen word and rare word.
learn_SPE()
의 num_symbols는 원하는 subword vocabulary size이다. BPE의 서브워드 생성은 높은 frequency occurrence에 따라 생성되는데 이때 정의한 desired subword vocabulary size에 도달하거나 설정한 minimum frequency에 도달하면 반복(생성)
을 멈춘다.
local, aws둘다 학습 chembl25에서 augmentation 1이상설정 증강중에 커널 죽거나 쌍 얻는 중에 죽는다.
input을 작은데이터셋(10개 짜리나 )
으로하면 증강을 10 사이클을해도 0.4초 내에 끝난다. 즉 메모리의 문제로 추정.
SPE는 훈련시 인풋을 SMILES의 리스트로 받기에 MolTrans와 합칠때도 인풋 데이터셋을 SMILES로 해야할것 maybe.