def test_step(model: torch.nn.Module,
data_loader:torch.utils.data.DataLoader,
loss_fn:torch.nn.Module,
accuracy_fn,
device:torch.device=device
):
""" Performs a testing with model trying to learn on data_loader"""
test_loss,test_acc=0,0 <------The indent error is being shown here
model.eval()
with torch.inference_mode():
for X,y in test_dataloader:
#Send data to target device
X,y=X.to(device),y.to(device)
#1. forward pass
test_pred=model(X)
#2. Calculate loss
test_loss+=loss_fn(test_pred,y)
#3. Calculate accuracy
test_acc+=accuracy_fn(y_true=y,
y_pred=test_pred.argmax(dim=1))
#Calculate the test loss average per batch
test_loss/=len(test_dataloader)
#Calculate the test accuracy average per batch
test_acc/=len(test_dataloader)
##print out what is happening
print(f"Train Loss: {train_loss:.5f} | Test Loss: {test_loss:.5f} | Test Acc: {test_acc:.2f}%")
When I just press enter and go to next line with the indent from my IDE , it keep showing unexpected indent error, it shows the same when I remove the indent and try manually pressing tab button to put the indent
I had already done the training function already with the almost the same code(I only just slightly changed the name etc.) and it had no errors, I tried to give indents manually also with no success