:albemic: | Tests.
This commit is contained in:
11
training.py
11
training.py
@ -38,9 +38,9 @@ device = torch.device(args.device if torch.cuda.is_available() else "cpu")
|
||||
print(f"Using device: {device}")
|
||||
|
||||
mfcc_transform = T.MFCC(
|
||||
sample_rate=44100, # Adjust to your sample rate
|
||||
sample_rate=44100,
|
||||
n_mfcc=20,
|
||||
melkwargs={'n_fft': 2048, 'hop_length': 512} # adjust n_fft and hop_length to your needs.
|
||||
melkwargs={'n_fft': 2048, 'hop_length': 256}
|
||||
).to(device)
|
||||
|
||||
def gpu_mfcc_loss(y_true, y_pred):
|
||||
@ -49,7 +49,8 @@ def gpu_mfcc_loss(y_true, y_pred):
|
||||
min_len = min(mfccs_true.shape[2], mfccs_pred.shape[2])
|
||||
mfccs_true = mfccs_true[:, :, :min_len]
|
||||
mfccs_pred = mfccs_pred[:, :, :min_len]
|
||||
return torch.mean((mfccs_true - mfccs_pred)**2)
|
||||
loss = torch.mean((mfccs_true - mfccs_pred)**2)
|
||||
return loss
|
||||
|
||||
def discriminator_train(high_quality, low_quality, real_labels, fake_labels):
|
||||
optimizer_d.zero_grad()
|
||||
@ -99,7 +100,7 @@ dataset = AudioDataset(dataset_dir, device)
|
||||
|
||||
# ========= SINGLE =========
|
||||
|
||||
train_data_loader = DataLoader(dataset, batch_size=128, shuffle=True)
|
||||
train_data_loader = DataLoader(dataset, batch_size=16, shuffle=True)
|
||||
|
||||
# Initialize models and move them to device
|
||||
generator = SISUGenerator()
|
||||
@ -161,7 +162,7 @@ def start_training():
|
||||
if debug:
|
||||
print(d_loss, combined_loss, adversarial_loss, mfcc_l)
|
||||
scheduler_d.step(d_loss)
|
||||
scheduler_g.step(combined_loss)
|
||||
#scheduler_g.step(combined_loss)
|
||||
|
||||
# ========= SAVE LATEST AUDIO =========
|
||||
high_quality_audio = (high_quality_clip[0][0], high_quality_clip[1][0])
|
||||
|
Reference in New Issue
Block a user