Hi everyone
I tried to use scheduler however I faced with the below error:
name ‘StepLR’ is not defined
has anyone know how I can fix it?
Below my I wrote my training codes:
#training loop
loss = 0
epoch_num = 0
error = []
scheduler = StepLR(optimizer, step_size=20, gamma=0.5)
for epoch in range(num_epochs):
for spec in train_loader:
img = spec.cuda()
output = model (img)
loss = criterion (output,img)

optimizer.zero_grad()
loss.backward()
optimizer.step()
error.append(loss.item())
scheduler.step()


if epoch%10 == 9:
  epoch_num += epoch_num
  plt.plot(error)


  print ('\r Train Epoch : {}/{} \tLoss : {:.4f}'.format (epoch+1,num_epochs,loss/32))

model_save_name = ‘Autoencoder for Li project  11 feb(2) (mid power) febTanh activation function Feb 2020 DMSO dataset’
path = F"/content/drive/My Drive/{model_save_name}"
torch.save(model.state_dict(), path)
thanks you