Code Monkey home page Code Monkey logo

Comments (6)

Exuro889 avatar Exuro889 commented on August 17, 2024 5

Make sure your class labels are 0 and 1. I'm guessing the reason 151 works is because your label values fit within that range. The model afaik is trying to allocate a position in a one hot vector for each pixel, so if your label is outside the range of that vector then it will go nan.

from fcn.tensorflow.

xtudbxk avatar xtudbxk commented on August 17, 2024

It's funny. And I also train the code on my dataset. When the NUM_OF_CLASSES is less than 60, the loss is Nan. And when I change the NUM_OF_CLASSES to 61, it works.
After some experiments, I found some results:
First, the direct reason is because the values of conv1_1 is Nan when the NUM_OF_CLASSES is less than 60. But the input image is not Nan. Second, what really matters is the NUM_OF_CLASSES in the third transpose convolution. That's saying it's no matter how you change the NUM_OF_CLASSES in the first transpose convolution.
But unfortunatly, I didn't find the reson and don't know how to fix it.
Do you fix it ?
Thanks,

from fcn.tensorflow.

rayhou0710 avatar rayhou0710 commented on August 17, 2024

Agree with @Exuro889 . Just double check you label.

from fcn.tensorflow.

abc8350712 avatar abc8350712 commented on August 17, 2024

@xtudbxk I have found the problem.I checked my dataset and surprisingly the max value of my label is 2.No wonder that 2 classes didn't work.I strongly suggest you checking your label again to make sure the num of labels is 60.
Meanwhile,thanks you @rayhou0710 @Exuro889

from fcn.tensorflow.

xtudbxk avatar xtudbxk commented on August 17, 2024

@abc8350712 @Exuro889
Thanks for your help, I just get the loss which is not nan through your ways.

from fcn.tensorflow.

shekkizh avatar shekkizh commented on August 17, 2024

Sorry for the late response. The above comment by @Exuro889 does solve the problem.
Just fyi in the documentation for tf.nn.sparse_softmax_cross_entropy_with_logits you will notice the labels are to be in range [0, num_classes). This is the same conclusion made in the above comments. This is just how the function is implemented.

from fcn.tensorflow.

Related Issues (20)

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.