Code Monkey home page Code Monkey logo

Comments (1)

dfdx avatar dfdx commented on June 9, 2024 1

Yes, this is expected. In both - Julia 0.5 and 0.6 operator .* is allowed on scalars and behaves the same way as *. The reason to use .* in the corresponding derivative rule is to support broadcasting for tensors. In short, when rdiff can't find tensor differentiation rule for some operation (e.g. log()), it looks for the corresponding rule for scalars instead an infers rule for tensors. Having .* instead of * in scalar rules is the simplest way to make scalar rules to work in both cases.

Note, that this may totally change once Julia 0.6 is out and XDiff is adapted to support new broadcasting rules.

It doesn't mean your example shouldn't work in the current version, though. simplify (as well as many other transformations here) work via a set of extensible rules, and you can easily define new ones:

julia> simplify(:(0.5 .* (2x)))
:(0.5 .* (2x))

julia> @simple_rule (0.5 .* (2 * _x)) _x   # _x is a placeholder that matches anything

julia> simplify(:(0.5 .* (2x)))
:x

At some point I will add this rule to Espresso, but right now I'm a bit suspicious about .* and * since they play an important (and different!) roles in the differentiation process.

from xdiff.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.