Giter Club home page Giter Club logo

einig's People

Contributors

cooijmanstim avatar

Stargazers

 avatar

Watchers

 avatar  avatar

einig's Issues

Detect and break down exponential-space signatures

Signatures like bij,bjk,bkl->bil where some axis appears in more than two inputs trigger an "exponential-space" implementation that broadcasts everything into an intermediate tensor bij,bjk,bkl->bijkl and then reduces it bijkl->bil. This should be pretty easy to detect and break up into explicit steps, e.g. bij,bjk->bik followed by bik,bkl->bil.

Support destructuring flattened axes

einsum("bij,(ij)k->bk", x, y) where the leading axis of y is actually in the same space as the trailing axes of x, e.g. x has shape [B, I, J] and y is the result of flatting the leading axes of something shaped [I, J, K].

Wrapping tf.gradients

It is well known that tf.gradients (and its relatives in other frameworks) is an inflexible beast. Just how inflexible doesn't become clear until a better way is shown. Here's an einsum-inspired notation for multiplication by derivatives.

tf.gradients(y, x, grad_ys=z) computes something like einsum("i,ij->j", z, dy/dx) without the explicit computation of dy/dx. This is the only case supported.

Suppose we write this eingrad("i,i%j->j", z, y, x), where eingrad will take care of calling out to tf.gradients appropriately. The % symbol separates operands like , does, but additionally indicates that the operand to the left of it should be differentiated with respect to the operand to the right of it.

Full jacobians for vector y: eingrad("i%j->ij", y, x)
Hessians for scalar y: eingrad("j%k->jk", eingrad(",%j->j", y, x), x)
Batched gradients for scalar y: eingrad("b%bj->bj", y, x)
Jacobian-vector product: eingrad("i%j,j->i", y, x)
Batched Jacobian-vector product: eingrad("bi%bj,bj->bi", y, x)

These cases are ridiculously difficult and error-prone to implement with bare tf.gradients, requiring various kinds of loops, transpositions and reshapes and acute awareness of the fragile notion of connectedness in symbolic graphs (e.g. tf.gradients(y, tf.identity(x)) or tf.gradients(y, x[0]) does not work at all, whereas tf.gradients(tf.identity(y), x) and tf.gradients(y[0], x) do).

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.