File size: 287 Bytes
b91e31d
 
 
 
 
 
 
 
 
d091751
 
1
2
3
4
5
6
7
8
9
10
11
<pre>
for batch in dataloader:
    inputs, targets = batch
    inputs = inputs.to(device)
    targets = targets.to(device)
    outputs = model(inputs)
    loss = loss_function(outputs, targets)
    loss.backward()
    optimizer.step()
    scheduler.step()
    optimizer.zero_grad()</pre>