Git Product home page Git Product logo

Comments (4)

lostella avatar lostella commented on August 17, 2024 1

Again, I don't think there's a clean way of obtaining what you're looking for in general: once you sum two functions of the same type, you're already screwed since they will have the same set of fields.

The way I see it, either

  1. the fields you want to inspect reflect into some general property of functions, so that you can define the same property in terms of the property of the components, or
  2. you have a sufficiently restricted set of cases, such as "f is the Sum of multiple functions, some of which are of SqrNormL2", in which case you can also do something like
for component in f.fs
    if typeof(component) <: SqrNormL2
        # do something about component.lambda
    end
end

from proximaloperators.jl.

lostella avatar lostella commented on August 17, 2024

It’s hard for me to see how this could be done: That lambda parameter is very specific to SqrNormL2, why do you need it? To get to some general property of functions? Maybe Lipschitz constant or convexity modulus?

from proximaloperators.jl.

lostella avatar lostella commented on August 17, 2024

One option, in case you have a restricted combination of possible types, is to define access methods like

get_lambda(f::SqrNormL2) = f.lambda

get_lambda(f::Sum{Tuple{SqrNormL2, T}}) where T = f.fs[1].lambda

since multiple dispatch is awesome. But again, depending on how many combinations are allowed you may need to complicate the above example.

from proximaloperators.jl.

pylat avatar pylat commented on August 17, 2024

I actually need the linear mappings (in order to compute direction for a linesearch) that are precomposed with logisticlosses and then the whole thing is summed with sqrNorml2s.
The multiple dispatch suggestion would work but it is still kinda ugly to separate into cases. That's why I was thinking maybe it would be easier for the calculus rules to be blind to how they are created.
I guess with calculus functions like sum it can be tricky since the summed functions may have overlapping fields. But in other cases like precompose I guess it can be done without issues. But then again I didn't think it through. Any way I'll go with your suggestion.

from proximaloperators.jl.

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.