Git Product home page Git Product logo

hw1's People

Contributors

ashertrockman avatar jacobtyo avatar leslierice1 avatar navalnica avatar tqchen avatar zkolter avatar zwang86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hw1's Issues

test_transpose_forward() out of index

839DDE6C20F7F9DC70F1589A4923F71B 839DDE6C20F7F9DC70F1589A4923F71B
def test_transpose_forward():
    np.testing.assert_allclose(ndl.transpose(ndl.Tensor([[[1.95]],
       [[2.7 ]],
       [[3.75]]]), axes=(1, 2)).numpy(), np.array([[[1.95]],
       [[2.7 ]],
       [[3.75]]]))

It should be 0 1 2 , 3d tensor, Why it is out of index?

Support sum(keepdims=False)

It better aligns with pytorch interface without adding much implementation complexity. It also makes users' life easier because they could avoid the need to calculate the dimensions and reshape() before a broadcast.

Tests should check that grad has correct dtype

Many random-float64-promotion complaints from hw2 can be traced to problematic ops implementation in hw1. Given that autograd didn't provide interface to cast Tensor's dtype, the dtype must be consistent from the beginning. Tests for gradient() methods should check that grad.dtype is "smaller" (won't cause promotion) than inputs[i].dtype

`__rsub__=__sub__` is a problem?

I find that in the codebase:

class Tensor(Value):
    __rsub__ = __sub__

Here is a test case:

import needle as ndl
1 - ndl.Tensor([0.5, 2.0, 3.0])   # get needle.Tensor([-0.5  1.   2. ]), which is wrong

Propose a hack data of Summation operation

Hello!

A implementation like this may pass the original test data.

def gradient(self, out_grad, node):
        return Tensor(array_api.ones_like(out_grad))

But when given 2 matrix , it fail.

So I sincerely propose to add this sample to function summation_backward() in test_autograd_hw.py of hw1

gradient_check(lambda A,C : ndl.summation(ndl.reshape(A,shape=(10,5))+C, axes=None),
                   ndl.Tensor(np.random.randn(50)),
                   ndl.Tensor(np.random.randn(10,5)), backward=True)

this originates from the last sample of function test_compute_gradient() with other operations removed.

I hope this may discover problems earlier to save time.
Thanks for your attention.

Add tests for PowerScalar and Exp TensorOps

test_autograd_hw.py doesn't have any tests for both compute and gradient methods of PowerScalar class. Same for Exp class. Adding tests will verify that our implementation is correct.

Hw1 question 2 issue

I have a problem about test code of HW1 question2. In gradient_check() function, out.backward() needs to call compute_gradient_of_variables() function which is implemented in question4. How to verify code in question2 without implementation of compute_gradient_of_variables() ? I am confused.

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.