GithubHelp home page GithubHelp logo

blackbox-fusion's People

Contributors

hqminh avatar

Stargazers

 avatar  avatar  avatar  avatar

blackbox-fusion's Issues

Gradient estimation trick is not that accurate

Your gradient estimation method, even though seems valid from the justification in the paper, gives a rather poor approximation. I modified your estimation method a little and ended up with more accurate gradients df(x,y) / dy at (x=0, y=1) for the multivariate function f(x,y) = -( x^2 + y^2).

In [1]: import random

In [2]: def func(fn, x, y, n, k):
   ...:     d1 = 0
   ...:     d2 = 0
   ...:     py = fn(x, y)
   ...:     for i in range(n):
   ...:         z = random.gauss(0, 1)
   ...:         yz = y + k * z
   ...:         pyz = fn(x, yz)
   ...:         dz1 = z / (n * k) * (pyz - py)   # Original 
   ...:         dz2 = (pyz - py) / (n * k * z)   # My modification with z in the denominator
   ...:         d1 += dz1
   ...:         d2 += dz2
   ...:     return d1, d2
   ...:

In [3]: fn = lambda x,y: -( x**2 + y**2)

In [4]: func(fn, 0, 1, 10, 0.001)
Out[4]: (-4.448181664467705, -1.9997430254634005)

In [5]: func(fn, 0, 1, 10, 0.001)
Out[5]: (-2.7221374341028843, -1.9999746498524409)

In [6]: func(fn, 0, 1, 10, 0.001)
Out[6]: (-2.2207592930502966, -1.9996130200338962)

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.