os.path.join("./out", opt.opath), "ae_n{}_b{}_{}".format(opt.n_fft, opt.n_mels, middle_size)) print('final output-path: {}'.format(statepath)) os.makedirs(statepath, exist_ok=True) # log parameters log_file = open(os.path.join(statepath, "params.txt"), "w") log_file.write(str(opt)) log_file.close() dset = SoundfileDataset(ipath=ipath, out_type="ae", normalize=True) if DEBUG: print('warning, debugging turnned on!') dset.data = dset.data[:100] tset, vset = dset.get_split(sampler=False, split_size=0.2) TLoader = DataLoader(tset, batch_size=batch_size, shuffle=True, drop_last=True, num_workers=num_workers) VLoader = DataLoader(vset, batch_size=batch_size, shuffle=False, drop_last=True, num_workers=num_workers) vae = AutoEncoder(n_mels, encode=encode_size, middle=middle_size)
batch_size=opt.batch_size, shuffle=True, num_workers=int(opt.workers)) Iset = DatasetCust(opt.dataroot, transform=transforms.Compose([ transforms.ToPILImage(), transforms.Resize((opt.image_size, opt.image_size)), transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)), ])) assert Iset if opt.debug: Mset.data = Mset.data[:100] assert len(Iset) > len(Mset) Iset.data = Iset.data[:len(Mset)] assert len(Iset) == len(Mset) Iloader = torch.utils.data.DataLoader(Iset, batch_size=opt.batch_size, shuffle=True, num_workers=int(opt.workers)) # Optimizers optimizer_D = torch.optim.Adam(discriminator.parameters(), lr=opt.lrD, betas=(opt.b1, opt.b2)) optimizer_G = torch.optim.Adam(generator.parameters(), lr=opt.lrG,
datapath = "./mels_set_f{}_h{}_b{}".format(n_fft, hop_length, n_mels) statepath = "./lstm_f{}_h{}_b{}_no_max".format(n_fft, hop_length, n_mels) #statepath = "conv_small_b128" device = "cuda" filt_genre = None #filt_genre = ['Experimental', 'Instrumental', 'International', 'Pop'] dset = SoundfileDataset("./all_metadata.p", ipath=datapath, out_type="mel", normalize=NORMALIZE, n_time_steps=n_time_steps, filter_list=filt_genre) if DEBUG: dset.data = dset.data[:2000] tset, vset = dset.get_split(sampler=False) TLoader = DataLoader(tset, batch_size=batch_size, shuffle=True, drop_last=True, num_workers=num_workers) VLoader = DataLoader(vset, batch_size=batch_size, shuffle=False, drop_last=True, num_workers=num_workers) model = LSTM(n_mels, batch_size, num_layers=n_layers)