Is it proper to do this torch.optim.Adam(net.parameters()) after this net(inputs.float())? I need it so I define the network in the forward for necessary reasons.
    for i, [inputs, labels] in enumerate(trainloader):
        inputs = inputs.to(device)
        labels = labels.to(device)

        # Forward + backward + optimize
        outputs = net(inputs.float())

        optimizer = torch.optim.Adam(net.parameters())
        optimizer.zero_grad()

        loss = criterion(outputs, labels.float())
        loss.backward()
        optimizer.step()