nikita-savelyevv / ennf Goto Github PK
View Code? Open in Web Editor NEWEducation Neural Network Framework
Education Neural Network Framework
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.
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.