Hi, I need some help training a network I have built utilizing wavelet transformed audio data.
I first have to pass the coefficients to an autoencoder, but the autoencoder doesn’t appear to be training.
Here are the mean losses for each epoch I got using an MSE Loss function, Adam, and a Learning rate of 0.015.
3.381066894531250000e+01
3.342230606079101562e+01
3.351392745971679688e+01
3.369192504882812500e+01
3.370663070678710938e+01
3.349161911010742188e+01
3.357623291015625000e+01
3.387789916992187500e+01
3.396487808227539062e+01
3.358479309082031250e+01
3.366595840454101562e+01
3.371033096313476562e+01
3.360509109497070312e+01
3.359120559692382812e+01
3.379703140258789062e+01
3.371158599853515625e+01
3.357886505126953125e+01
3.359542846679687500e+01
3.374793624877929688e+01
3.364756011962890625e+01
I haven’t had any luck with changing the loss functions or the learning rate, so I think that there may be an error somewhere in my training function.
def train(self):
filenames = []
train_directory = 'DATA/TRAIN/'
os.chdir("DATA/TRAIN/")
filecount = 0
for file in glob.glob("*.wav*"):
filecount = filecount + 1
filenames.insert(filecount, train_directory + file)
os.chdir("..")
os.chdir("..")
learning_rate = 0.015
optimizer = optim.Adam(self.parameters(), lr = learning_rate)
criterion = nn.MSELoss()
criterion.float()
random.shuffle(filenames)
epoch_loss_pathname = 'Loss/EPOCHS/epoch_loss_lvl_' + str(self.level)
epoch_losses = np.array([])
if os.path.isfile(epoch_loss_pathname):
epoch_losses = np.loadtxt(epoch_loss_pathname)
total_losses = 0
for idx, flnm in enumerate(filenames):
coeffs, max_level, num_chunks, samplerate = preprocess(flnm)
print('Training with ' + str(idx) + '/' + str(len(filenames)) + ' :: LEVEL: ' + str(self.level))
print('')
optimizer.zero_grad()
file_loss = 0
rand_chunks = np.random.randint(num_chunks, size = 5)
for chk in rand_chunks:
params = [self.level, coeffs[chk][self.level]]
out = auto_forward_process(params)
data_tensor = torch.from_numpy((coeffs[chk][self.level])).view(1, len(coeffs[chk][self.level]))
data_tensor = data_tensor.float()
loss = criterion.forward(out, Variable(data_tensor))
loss.backward()
optimizer.step()
file_loss += loss.data.numpy()
total_losses += loss.data.numpy()
print('Mean File Loss: ' + str(file_loss/5))
epoch_loss = total_losses/len(filenames)
print('Mean Epoch Loss: ' + str(epoch_loss))
torch.save(self.state_dict(), self.parameter_pathname)
return epoch_loss
Can anybody help me figure out why my weights don’t appear to be updating or responding to training?