Code Monkey home page Code Monkey logo

Comments (13)

lucasb-eyer avatar lucasb-eyer commented on May 20, 2024 3

I've seen people successfully use L-BFGS with neural nets, given they use large batches. So I personally would try to average the gradient over all my images before I run an L-BFGS step.

Averaging gradients over all images is the same as computing the gradient of the total loss if the total loss is the sum over each image's loss. So I feel like it should work this way.

But yeah, the caveat is that I haven't tried this, and as usual with nonlinear optimization, you never know until you try 😉 Hence I'm very curious to hear back from anyone trying this.

Also, re-opening since there's more information now, albeit not from OP.

from pydensecrf.

lucasb-eyer avatar lucasb-eyer commented on May 20, 2024 1

Disclaimer: I've not used densecrf with learning.

Since it's learning the parameters by gradient-based optimization (l-bfgs here), my guess is that you could do it similarly to neural networs: compute the gradients on say B random pictures, so you get B gradients. Average them, then do an optimizer step. Then pick B next pictures, compute average gradient, do an optimizer step. This way you should in theory optimize the parameters over all pictures.

I'm not sure how well this will work in practice with dense crfs, but if you try it, I'm curious (and others probably too) so please report back whether it worked or not. And of open a PR with any changes you needed :)

from pydensecrf.

dhawan98 avatar dhawan98 commented on May 20, 2024 1

hey! if any of you have coded or found the above code. can you point me towards it, or send me the code. I need to run the training process on a set of images and predict on some other image.

from pydensecrf.

lucasb-eyer avatar lucasb-eyer commented on May 20, 2024

Hi Luka,

I'm sorry, it looks like I completely missed your issue! I believe that I currently didn't wrap the learning part of the API at all, only the inference, so is it possible that you mean "run inference" as opposed to "train"?

from pydensecrf.

lucasb-eyer avatar lucasb-eyer commented on May 20, 2024

Closing due to inactivity and unclarity about actual issue.

from pydensecrf.

lishi0927 avatar lishi0927 commented on May 20, 2024

Hello, I also have the same question.
I have some training images and test images, So how to train the CRF model and get the parameters, do you have any piece of advice about learning?

from pydensecrf.

lucasb-eyer avatar lucasb-eyer commented on May 20, 2024

Funny you ask, I added a few more pointers about learning to the README just yesterday!

I myself don't have the time (and need) to implement learning, but I think it should be straightforward to add for someone motivated enough. Hope these pointers can give you a start, and should you manage to add learning, I'd be happy about a pull-request!

from pydensecrf.

lishi0927 avatar lishi0927 commented on May 20, 2024

Okay, thank you for your reply.

from pydensecrf.

lishi0927 avatar lishi0927 commented on May 20, 2024

Ah, and i have another question about learning. I have read the original learning cpp code and find that they use only one image optimize the CRF function and get all learning parameters. So if I want to train N images, I have to get N couples of learning parameters and choose the best learning parameters that get the minimize error to the other images, or do you have any piece of advice to get the learning parameters of the multiple images?
Thank you.

from pydensecrf.

lishi0927 avatar lishi0927 commented on May 20, 2024

Okay, thanks for your advice and i will have a try.

from pydensecrf.

reynoldscem avatar reynoldscem commented on May 20, 2024

I think part of the issue with averaging gradients won't come from the fact we're trying to optimise a CRF, but rather that we're using L-BFGS - as it is using line searching & an approximate Hessian to calculate updates. Still, worth a try at least.

from pydensecrf.

manishh avatar manishh commented on May 20, 2024

Useful discussion, anything added to the repo on learning?

from pydensecrf.

Mikeflames avatar Mikeflames commented on May 20, 2024

@dhawan98, @lucasb-eyer Did you find the code for the Set of images? If found, please direct me .
Thanks

from pydensecrf.

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.