-
Notifications
You must be signed in to change notification settings - Fork 9
/
train.py
51 lines (40 loc) · 1.3 KB
/
train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
""" Python script to train EBEN model """
import torch
from pytorch_lightning import LightningDataModule, LightningModule, Trainer
from src.discriminator import DiscriminatorEBENMultiScales
from src.eben import EBEN
from src.generator import GeneratorEBEN
from src.librispeech_datamodule import CustomLibriSpeechDM
def train():
"""actual training function"""
# Instantiate datamodule
datamodule: LightningDataModule = CustomLibriSpeechDM(
path_to_dataset="./mls_french",
sr_standard=16000,
bs_train=16,
len_seconds_train=2,
num_workers=4,
)
# Instantiate EBEN
generator: torch.nn.Module = GeneratorEBEN(
m=4, # decimation factor of PQMF
n=32, # PQMF kernel size
p=1 # number of informative bands
)
discriminator: torch.nn.Module = DiscriminatorEBENMultiScales(
q=3 # number of bands refined by PQMF discriminators
)
eben: LightningModule = EBEN(
generator=generator, discriminator=discriminator, lr=0.0003, betas=(0.5, 0.9)
)
trainer: Trainer = Trainer(
gpus=1,
max_epochs=13,
enable_checkpointing=False,
logger=False,
limit_val_batches=0,
)
# Fit
trainer.fit(model=eben, datamodule=datamodule)
if __name__ == "__main__":
train()