Hello. I am new on machine learning and pytorch. ? I am doing segmentation and using the MSEloss function for calculating loss but i want to find the accuracy as well. I have tried different example but didn’t find it. Please help me following is my code and the shapes.
for data, target in train_loader:
    data = data.to(device) 
    target  = target.to(device=device, dtype=torch.int64)

    input_var = Variable(data.float())
    target_var = Variable(target.float())

    optimizer.zero_grad()
    output = model(input_var)
    loss = criterion(output, target_var)
    dice =  dice_coef(output,target)

    loss.backward()
    optimizer.step()

    train_loss += loss.item()*data.size(0)
    train_metric =  dice*data.size(0)

Shapes:
target_var  torch.Size([2, 3, 512, 512])
oututput  torch.Size([2, 3, 512, 512])