GithubHelp home page GithubHelp logo

How to use custom loss ? about tianshou HOT 8 CLOSED

thu-ml avatar thu-ml commented on May 5, 2024
How to use custom loss ?

from tianshou.

Comments (8)

duburcqa avatar duburcqa commented on May 5, 2024 1

Ok, I got your point and I agree with you. But what about adding a loss_fn in the abstract base class for policies, that is basically doing nothing by default but can be overridden by the user? Because I really don't like the idea to have to overwrite 'learn' itself since it is a major source of error.

In this case, it is not a custom loss strictly speaking, but rather additional component to the original loss function (regularization), that may depend on the actor. So that it only consists in an extra function call before calling backward. I don't know if doing so is usual or not.

from tianshou.

Trinkle23897 avatar Trinkle23897 commented on May 5, 2024

That's a good question. Currently, you can either inherit the policy class (as you mentioned) or change the original framework's code to meet your expectations.

It can be discussed further. Some existing frameworks (like RLlib) modularized the loss function part. But in my opinion, this could be inconvenient for further development. Since the loss function is highly customizable, making the abstraction of the loss function will double the code complexity.

from tianshou.

duburcqa avatar duburcqa commented on May 5, 2024

@Trinkle23897 Up !

from tianshou.

Trinkle23897 avatar Trinkle23897 commented on May 5, 2024

@Trinkle23897 Up !

I have no time after #106 before this Friday...Many things to do

from tianshou.

duburcqa avatar duburcqa commented on May 5, 2024

No problem ! I can do it ! But what do you think about the idea ?

from tianshou.

Trinkle23897 avatar Trinkle23897 commented on May 5, 2024

I think that add loss_fn is okay, but what's its input?

from tianshou.

oldcricket avatar oldcricket commented on May 5, 2024

@duburcqa It's a great idea to make it easier with a customized loss. I wondered if you have made any progress on that. Thanks!

from tianshou.

MischaPanch avatar MischaPanch commented on May 5, 2024

The loss is an integral part of the algorithm, so maybe inheriting and overriding is better than allowing users to pass custom losses. It's a central design question, I don't see it being necessary for the 1.0.0 release, but would keep the issue open

from tianshou.

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.