GithubHelp home page GithubHelp logo

Comments (5)

ckolluru avatar ckolluru commented on August 20, 2024 1

Why are the metrics multiplied by the batch size, added cumulatively and then divided by the total number of samples during printing?

It seems like this will print a scaled version of the average metric value (from print_metrics), depending on the batch size. Please correct me if I'm wrong.

from pytorch-unet.

usuyama avatar usuyama commented on August 20, 2024

You're right. The current code uses BCE, so each pixel can have multiple classes i.e. multi-labels.

To make it a single class for each pixel i.e. multi-class, you can use CE. I think you need to use reshape/view to 2d.

from pytorch-unet.

sarmientoj24 avatar sarmientoj24 commented on August 20, 2024

Hi, I am having a problem dealing with a multi-class task where dimensions are like these:

MASK TARGET: torch.Size([4, 1, 600, 900, 3])
OUTPUT: torch.Size([4, 5, 600, 900]

@ckolluru Have you created your loss function for multiclass already?

from pytorch-unet.

shahzad-ali avatar shahzad-ali commented on August 20, 2024

Why are the metrics multiplied by the batch size, added cumulatively and then divided by the total number of samples during printing?

The reason is some batches (i.e. the last batch) may have fewer training examples than all the other batches. Dividing the product metric * batch_size by total_samples is a better estimate of a used metric for a complete epoch. Skimming through the example Training a Classifier from PyTorch tutorials reveals that the same strategy was used in section "4. Train the network" is the important one where the statistics were printed.

It seems like this will print a scaled version of the average metric value (from print_metrics), depending on the batch size. Please correct me if I'm wrong.

That's true! You may get a better insight into this topic by reading How is the loss for an epoch reported?

from pytorch-unet.

AlphonsG avatar AlphonsG commented on August 20, 2024

If you want to use cross entropy make sure you're not applying sigmoid function beforehand.

from pytorch-unet.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.