GithubHelp home page GithubHelp logo

Target function returns NaN about adaptive HOT 5 CLOSED

bonh avatar bonh commented on June 16, 2024
Target function returns NaN

from adaptive.

Comments (5)

basnijholt avatar basnijholt commented on June 16, 2024 1

Maybe you just want to make it less likely that something in that area gets chosen. You can do that with

def custom_loss(simplex, values, value_scale):
    loss = adaptive.learner.learnerND.default_loss(simplex, values, value_scale)
    if any(np.isnan(v) for v in values):
        return loss / 10
    return loss

learner = adaptive.LearnerND(..., loss_per_simplex=custom_loss)

from adaptive.

basnijholt avatar basnijholt commented on June 16, 2024

You probably need a custom loss function. Where if a NaN is returned, you set the region to 0 loss, meaning it won't be picked again.

Which learner are you using?

from adaptive.

bonh avatar bonh commented on June 16, 2024

Okay, sounds good, I'll try that.

I'm using LearnerND for $R^3 \rightarrow R^1$.

from adaptive.

basnijholt avatar basnijholt commented on June 16, 2024

OK, then try something like:

def custom_loss(simplex, values, value_scale):
    if any(np.isnan(v) for v in values):
        return 0.0
    return adaptive.learner.learnerND.default_loss(simplex, values, value_scale)

learner = adaptive.LearnerND(..., loss_per_simplex=custom_loss)

Note that I didn't test this 😅

from adaptive.

bonh avatar bonh commented on June 16, 2024

That seems to work - thanks!

from adaptive.

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.