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

TIP. 학습용 데이터가 1시간 이하일때 학습성능을 끌어올리는법 #23

Closed
popop098 opened this issue Apr 2, 2023 · 9 comments

Comments

@popop098
Copy link

popop098 commented Apr 2, 2023

training/config.yaml혹은 training/config_nsf.yamlendless_ds 값을 true로 수정하면 한번에 2000회씩 학습하여 학습성능을 극대화하며 학습시간을 단축시킬 수 있습니다.

아래 예제 total_loss 값을 주의깊게 확인해보세요.

EXAMPLE )

| Mel losses: {'ssim': 0.5, 'l1': 0.5}
| Load HifiGAN:  checkpoints/nsf_hifigan/model
Removing weight norm...
04/02 04:58:28 PM gpu available: True, used: True
| model Trainable Parameters: 33.709M
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.93it/s]
sample time step:  98%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌   | 98/100 [00:01<00:00, 81.04it/s] 
==============
 valid results: {'total_loss': 0.9917, 'mel': 0.9917}
==============

sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 85.87it/s]
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.98it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.80it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.95it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.37it/s] 
Validating:  80%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                   | 4/5 [00:19<00:04,  4.31s/batch] 
==============0%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:22<00:00,  4.05s/batch] 
 valid results: {'total_loss': 0.0858, 'mel': 0.0858}
==============

Epoch 1: : 2001batch [08:54,  4.02batch/s, batch_size=10, lr=0.0004, mel=0.106, step=2000]                                                                                                                                         04/02 05:07:33 PM Epoch 00000@2000: saving model to checkpoints/test/model_ckpt_steps_2000.ckpt
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 86.66it/s]
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.18it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.17it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.30it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.38it/s] 
Validating:  80%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                   | 4/5 [00:18<00:04,  4.15s/batch] 
==============0%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:21<00:00,  4.01s/batch] 
 valid results: {'total_loss': 0.0953, 'mel': 0.0953}
==============

Epoch 1: : 4001batch [17:37,  4.00batch/s, batch_size=10, lr=0.0004, mel=0.0316, step=4000]                                                                                                                                        04/02 05:16:16 PM Epoch 00000@4000: saving model to checkpoints/test/model_ckpt_steps_4000.ckpt
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 85.76it/s]
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.84it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.78it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.99it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.51it/s] 
Validating:  80%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                   | 4/5 [00:18<00:04,  4.17s/batch] 
==============0%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:22<00:00,  4.02s/batch] 
 valid results: {'total_loss': 0.0156, 'mel': 0.0156}
==============

Epoch 1: : 6001batch [26:21,  3.91batch/s, batch_size=10, lr=0.0004, mel=0.0549, step=6000]                                                                                                                                        04/02 05:25:00 PM Epoch 00000@6000: saving model to checkpoints/test/model_ckpt_steps_6000.ckpt
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.64it/s]
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.52it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.17it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.84it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.05it/s] 
Validating:  80%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                   | 4/5 [00:18<00:04,  4.18s/batch] 
==============0%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:22<00:00,  4.01s/batch] 
 valid results: {'total_loss': 0.1817, 'mel': 0.1817}
==============

Epoch 1: : 8001batch [35:11,  4.04batch/s, batch_size=10, lr=0.0004, mel=0.0174, step=8000]                                                                                                                                        04/02 05:33:49 PM Epoch 00000@8000: saving model to checkpoints/test/model_ckpt_steps_8000.ckpt
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 85.64it/s]
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.12it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.65it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.97it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.15it/s] 
Validating:  80%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                   | 4/5 [00:18<00:04,  4.22s/batch] 
==============0%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:22<00:00,  4.00s/batch] 
 valid results: {'total_loss': 0.0162, 'mel': 0.0162}
==============

Epoch 1: : 10001batch [44:32,  4.10batch/s, batch_size=10, lr=0.0004, mel=0.0612, step=10000]                                                                                                                                      04/02 05:43:10 PM Epoch 00000@10000: saving model to checkpoints/test/model_ckpt_steps_10000.ckpt
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 85.20it/s]
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.73it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.80it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.95it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 81.51it/s] 
Validating:  80%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                   | 4/5 [00:18<00:04,  4.14s/batch] 
==============0%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:21<00:00,  3.98s/batch] 
 valid results: {'total_loss': 0.0057, 'mel': 0.0057}
==============

Epoch 1: : 12001batch [53:17,  4.04batch/s, batch_size=10, lr=0.0004, mel=0.00924, step=12000]                                                                                                                                     04/02 05:51:55 PM Epoch 00000@12000: saving model to checkpoints/test/model_ckpt_steps_12000.ckpt
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 86.65it/s]
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.93it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.93it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.19it/s] 
sample time step: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 80.79it/s] 
Validating:  80%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                   | 4/5 [00:18<00:04,  4.20s/batch] 
==============0%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:22<00:00,  4.03s/batch] 
 valid results: {'total_loss': 0.0085, 'mel': 0.0085}
==============
@seohyunp69
Copy link

seohyunp69 commented Apr 2, 2023

그러면 저렇게하면 파일에 있는 ds workers 값은 무시되는건가요?
저렇게하고 8시간 돌렸는데 2000스텝밖에 안가네여..

@MoorDev
Copy link

MoorDev commented Apr 2, 2023

그러면 저렇게하면 파일에 있는 ds workers 값은 무시되는건가요? 저렇게하고 8시간 돌렸는데 2000스텝밖에 안가네여..

CUDA설정이 되어있지 않은것 같습니다
set CUDA_VISIBLE_DEVICES=0 (Windows기준) 이게 설정이 안 되어있나요?

저도 이 옵션 켜고 돌리고 있는데 1Epoch가 오래걸리는 문제가 있지만 48시간에 360000스텝정도 진행되는것으로 보아 GPU가 일을 안 하는 듯 합니다.
nvidia그래픽 카드의 경우 nvidia-smi화면에서 GPU Util이 학습시 몇%인지 확인해보세요. rocm은 잘 모르겠네요.

그리고 ds_worker는 CPU작업시 쓰는 코어 갯수인데 MEL스펙트럼을 만들거나 (이건 푸리에 변환연산이라 GPU단독이 불가능함) 리샘플링작업을 할때 몇개의 스레드로 할건가를 결정합니다. CPU학습때는 크게 관계가 없는것 같습니다

@wlsdml1114
Copy link
Owner

공식문서에는 다음처럼 나와있네요

If your dataset is too small, each epoch will pass very fast. 
Setting this to True will treat 1000 epochs as a single one.

endless_ds가 뭐의 줄임말인지는 모르겠는데 말씀하신대로 1000 epoch(공식문서 기준)을 하나의 epoch으로 처리하는거 같네요.
중간에 validation이 빠져서 속도가 빨라지는거 같은데, 성능이 향상되는지는 잘 모르겠습니다.

혹시 비교 해보셨다면 체감이 되시나요?

@popop098
Copy link
Author

popop098 commented Apr 3, 2023

공식문서에는 다음처럼 나와있네요

If your dataset is too small, each epoch will pass very fast. 
Setting this to True will treat 1000 epochs as a single one.

endless_ds가 뭐의 줄임말인지는 모르겠는데 말씀하신대로 1000 epoch(공식문서 기준)을 하나의 epoch으로 처리하는거 같네요.
중간에 validation이 빠져서 속도가 빨라지는거 같은데, 성능이 향상되는지는 잘 모르겠습니다.

혹시 비교 해보셨다면 체감이 되시나요?

저 같은 경우는 솔직히 데이터가 준수하게 준비된 상태는 아니라서 드라마틱하게 좋아지지는 않은것같으나 false로 했을때보단 그나마 괜찮아진듯합니다.

별개의 주제지만 다른 pretraining model들을 발견해서 config파일내의 pe_ckpt값이 pretrained된 모델을 선택하는건지 궁금해서 직접 수정하여 훈련후 비교해볼예정입니다. 이 또한 유의미한 변화가 생길경우 이슈로 남겨드리겠습니다.
+) 코랩에는 pretrained된 모델을 선택하는 부분이 있는걸로보아 가능할것으로 보입니다.

@MoorDev
Copy link

MoorDev commented Apr 3, 2023

공식문서에는 다음처럼 나와있네요

If your dataset is too small, each epoch will pass very fast. 
Setting this to True will treat 1000 epochs as a single one.

endless_ds가 뭐의 줄임말인지는 모르겠는데 말씀하신대로 1000 epoch(공식문서 기준)을 하나의 epoch으로 처리하는거 같네요.
중간에 validation이 빠져서 속도가 빨라지는거 같은데, 성능이 향상되는지는 잘 모르겠습니다.
혹시 비교 해보셨다면 체감이 되시나요?

저 같은 경우는 솔직히 데이터가 준수하게 준비된 상태는 아니라서 드라마틱하게 좋아지지는 않은것같으나 false로 했을때보단 그나마 괜찮아진듯합니다.

별개의 주제지만 다른 pretraining model들을 발견해서 config파일내의 pe_ckpt값이 pretrained된 모델을 선택하는건지 궁금해서 직접 수정하여 훈련후 비교해볼예정입니다. 이 또한 유의미한 변화가 생길경우 이슈로 남겨드리겠습니다. +) 코랩에는 pretrained된 모델을 선택하는 부분이 있는걸로보아 가능할것으로 보입니다.

전 pe_ckpt를 다르게 이해했습니다
use_pe 옵션에 대해 설명을 보면
MEL spectrogram에서 F0를 뽑는 알고리즘 사용이라고 되어있습니다. 그리고 그 모델이 pe_ckpt에 있는것이고요. (doc에 있는 설명자체가 워낙부실해서 제가 잘 못 이해한걸 수도 있습니다)

pretrained의 경우는 load에 pretrained모델을 넣고 돌리니까 파리미터를 미리 준비하고 학습을 하더군요. 진짜로 그런건지는 알 수가 없습니다만...(아무리봐도 파라미터 불러온뒤 이걸 적용하는 코드가 보이지 않음)
현재 endless_ds옵션켜고 2Epoch진행중입니다. 데이터는 한 시간반정도짜리고요. 5Epoch정도 되면 잠시 껐다가 inference해볼 생각입니다.

pretrained모델은 LIFE-DIFF-SVC-AI V1을 적용중입니다. (44.1kHz보코더가 GPU메모리 문제로 쓸수 없기 때문)

저도 확인 되는대로 이슈에 올려보겠습니다

@wlsdml1114
Copy link
Owner

공식문서에는 다음처럼 나와있네요

If your dataset is too small, each epoch will pass very fast. 
Setting this to True will treat 1000 epochs as a single one.

endless_ds가 뭐의 줄임말인지는 모르겠는데 말씀하신대로 1000 epoch(공식문서 기준)을 하나의 epoch으로 처리하는거 같네요.
중간에 validation이 빠져서 속도가 빨라지는거 같은데, 성능이 향상되는지는 잘 모르겠습니다.
혹시 비교 해보셨다면 체감이 되시나요?

저 같은 경우는 솔직히 데이터가 준수하게 준비된 상태는 아니라서 드라마틱하게 좋아지지는 않은것같으나 false로 했을때보단 그나마 괜찮아진듯합니다.
별개의 주제지만 다른 pretraining model들을 발견해서 config파일내의 pe_ckpt값이 pretrained된 모델을 선택하는건지 궁금해서 직접 수정하여 훈련후 비교해볼예정입니다. 이 또한 유의미한 변화가 생길경우 이슈로 남겨드리겠습니다. +) 코랩에는 pretrained된 모델을 선택하는 부분이 있는걸로보아 가능할것으로 보입니다.

전 pe_ckpt를 다르게 이해했습니다 use_pe 옵션에 대해 설명을 보면 MEL spectrogram에서 F0를 뽑는 알고리즘 사용이라고 되어있습니다. 그리고 그 모델이 pe_ckpt에 있는것이고요. (doc에 있는 설명자체가 워낙부실해서 제가 잘 못 이해한걸 수도 있습니다)

pretrained의 경우는 load에 pretrained모델을 넣고 돌리니까 파리미터를 미리 준비하고 학습을 하더군요. 진짜로 그런건지는 알 수가 없습니다만...(아무리봐도 파라미터 불러온뒤 이걸 적용하는 코드가 보이지 않음) 현재 endless_ds옵션켜고 2Epoch진행중입니다. 데이터는 한 시간반정도짜리고요. 5Epoch정도 되면 잠시 껐다가 inference해볼 생각입니다.

pretrained모델은 LIFE-DIFF-SVC-AI V1을 적용중입니다. (44.1kHz보코더가 GPU메모리 문제로 쓸수 없기 때문)

저도 확인 되는대로 이슈에 올려보겠습니다

@MoorDev 님 말씀이 맞는 거 같습니다.

use_pe=True
# F0 extraction algorithm for synthesizing audio from the Mel spectrogram. Changing this to False will use the input audio's F0.
# There is a slight difference in results between using True and False. Usually, setting it to True is better, but not always. It has almost no effect on the synthesizing speed. 
# (Regardless of what the value of the key parameter is, this value is always changeable and does not affect it)
# This function is not supported in 44.1kHz models and will be turned off automatically. Leaving it on will not cause any errors as well.

이렇게 되어있네요.

좀 더 찾아보니 F0가 fundamental frequency라고 소리쪽에서 사용하는 용어인것 같습니다.
https://wiki.aalto.fi/pages/viewpage.action?pageId=149890776

만약 use_pe가 true이면 입력 오디오의 F0값이 아닌 특정 알고리즘이나 모델을 이용해서 F0를 얻는 것 같네요

@popop098
Copy link
Author

popop098 commented Apr 3, 2023

load_ckpt에 pretrained 된 모델을 기입해야하는군요. 잘못알고있었네요😅
이 값을 기입하고 추가적으로 건드려야하는 옵션은 없는것일까요??

@MoorDev
Copy link

MoorDev commented Apr 3, 2023

load_ckpt에 pretrained 된 모델을 기입해야하는군요. 잘못알고있었네요😅 이 값을 기입하고 추가적으로 건드려야하는 옵션은 없는것일까요??

따로 더 건든건 없었습니다. 아마 기본설정 그대로 하면 Transfer Learning개념으로 되는게 아닐까 추측하고 있습니다

@wlsdml1114
Copy link
Owner

본 이슈는 README에 추가했습니다.

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

4 participants