GithubHelp home page GithubHelp logo

ennf's People

Contributors

nikita-savelyevv avatar

Watchers

 avatar  avatar  avatar

Forkers

nekedd

ennf's Issues

test_tensor_backward issue

in module nn_lib\tests\test_tensor_backward.py:
function
def test_exponent_gradient_scalar_2(self):

a = Tensor(3.1, requires_grad=True)
b = F.exp(a)
b.backward(Tensor(4))
self.assertAlmostEqual(a.grad.data, 4*np.exp(3.1), 5)
self.assertEqual(b.grad.data, 4)
in first assert give "not equal" output:

raise self.failureException(msg)
AssertionError: array(88.79179, dtype=float32) != 88.79180512576654 within 5 places (1.893191888768797e-05 difference)

i think issue with float types of default python float values and numpy float32. Default float type is float == float64 in numpy. But when we create Tensor instance, we use float32 type of numpy.
image

if we use float64 type in assertion, when we use float32 in Tensor not correct.

My solve this problem is change
row:
self.assertAlmostEqual(a.grad.data, 4*np.exp(3.1), 5)
to
self.assertAlmostEqual(a.grad.data, np.dot(4, np.exp(np.array(3.1, np.float32))), 5)
and test complete successfully!
image

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.