Update.
Before Width: | Height: | Size: 647 B |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 415 B After Width: | Height: | Size: 447 B |
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 711 B After Width: | Height: | Size: 700 B |
Before Width: | Height: | Size: 733 B After Width: | Height: | Size: 762 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 661 B After Width: | Height: | Size: 686 B |
Before Width: | Height: | Size: 648 B After Width: | Height: | Size: 649 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 129 B |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 415 B After Width: | Height: | Size: 447 B |
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 711 B After Width: | Height: | Size: 700 B |
Before Width: | Height: | Size: 727 B After Width: | Height: | Size: 753 B |
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 106 B |
Before Width: | Height: | Size: 661 B After Width: | Height: | Size: 686 B |
Before Width: | Height: | Size: 621 B After Width: | Height: | Size: 658 B |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 118 B |
|
@ -125,14 +125,14 @@ for epoch in range(epochs):
|
|||
loss.backward()
|
||||
optimizer_unsuper.step()
|
||||
if (i + 1) % 100 == 0:
|
||||
print(f"Epoch [{epoch+1}/{num_epochs}], Step [{i+1}/{n_total_steps}], Loss: {loss.item():.8f}")
|
||||
print(f"Epoch [{epoch+1}/{epochs}], Step [{i+1}/{n_total_steps}], Loss: {loss.item():.8f}")
|
||||
|
||||
# Train the model
|
||||
model.conv1.weight.requires_grad = False
|
||||
model.conv2.weight.requires_grad = True
|
||||
model.fc1.weight.requires_grad = True
|
||||
criterion = nn.CrossEntropyLoss()
|
||||
optimizer = torch.optim.SGD(filter(lambda p: p.requires_grad, model.parameters()), lr=0.6)
|
||||
optimizer = torch.optim.SGD(filter(lambda p: p.requires_grad, model.parameters()), lr=0.2)
|
||||
n_total_steps = len(train_loader)
|
||||
for epoch in range(num_epochs):
|
||||
for i, (images, labels) in enumerate(train_loader):
|
||||
|
|