I am using the code below to convert the model into mixed precision. And I have also commented the sigmoid line but still I am facing the issue.
    for i, (images, labels) in enumerate(train_loader):
        images, labels = images.float().to(device), labels.float().to(device)
        optimizer.zero_grad()
        with torch.cuda.amp.autocast():
            logits = classifier(images)
            loss = criterion(logits, labels)
        scaler.scale(loss).backward()
        scaler.step(optimizer)
        # Updates the scale for next iteration.
        scaler.update()

But I am getting the error on line scaler.scale(loss).backward(). I am getting the following error:
image1427×330 23.1 KB
Sorry for bugging you.