GithubHelp home page GithubHelp logo

Output from network about deepcl HOT 9 CLOSED

hughperkins avatar hughperkins commented on May 27, 2024
Output from network

from deepcl.

Comments (9)

hughperkins avatar hughperkins commented on May 27, 2024

Hmmm... been a long time since I looked at this... As far as the literal output to your question, you mean how to calculate the label given the probabilities? So it will just be whichever layer gives the maximum probability.

In the underlying c++ library though, the SoftMax layers has a method void getLabels(int *labels), https://github.com/hughperkins/DeepCL/blob/master/src/loss/SoftMaxLayer.cpp#L297 , which will do this for you. But I will need to ponder a bit how to expose this in the python layer, so you might want to just hack and paste that method into python for now, ie this code:

    for(int n = 0; n < batchSize; n++) {
        float *outputStack = output + n * numPlanes;
        float highestProb = outputStack[0];
        int bestPlane = 0;
        for(int plane = 1; plane < numPlanes; plane++) {
            if(outputStack[plane] > highestProb) {
                bestPlane = plane;
                highestProb = outputStack[plane];
            }
        }
        labels[n] = bestPlane;
    }

from deepcl.

m-smith avatar m-smith commented on May 27, 2024

Right, I figure I could do something like above. The issue is that the python wrapper's get output method doesn't provide access to all the planes....maybe just one or the max of each plane for each input.

from deepcl.

hughperkins avatar hughperkins commented on May 27, 2024

Hmmm, glancing through the code (since as I say, it's been a while :-P ), it looks like getOutput should return an array that is getOutputNumElements() long, and getOutputNumElements() is an abstract method of Layer, which is overridden by LossLayer, and simply returns the number of output elements of the previous layer.

So, in theory, if I'm reading correctly, the size of getOutput should be the same as the size of the output of the previous layer.

Can you post the code that you're using to test, and I can have a play?

from deepcl.

m-smith avatar m-smith commented on May 27, 2024

I dunno what I was looking at/doing..I revisited my test cases and this looks like its working perfectly...sorry for the trouble!

from deepcl.

hughperkins avatar hughperkins commented on May 27, 2024

Ok, cool :-) By the way, do you most need the predicted output label of each example, or do you most need the underlying probabilities?

from deepcl.

m-smith avatar m-smith commented on May 27, 2024

just the underlying probabilities is good enough for me, but I can defs see the use for a wrapper for the prediction...it would make it that much easier...

from deepcl.

hughperkins avatar hughperkins commented on May 27, 2024

Hi Matthew, ok, you mean, probabilities are enough, because you already have the code to convert to labels? or probabilities are what you are actually trying to obtain currently, dont need the labels?

from deepcl.

m-smith avatar m-smith commented on May 27, 2024

I need both, so I do need the labels, but I am already working with the probabilities so I don't mind computing the labels myself.

from deepcl.

hughperkins avatar hughperkins commented on May 27, 2024

Added in d70b598 . You can see test_lowlevel.py lines 66-68 for an example:

            lastLayer = net.getLastLayer()
            predictions = lastLayer.getLabels()
            print('predictions', predictions)

from deepcl.

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.