Code Monkey home page Code Monkey logo

module-1's Introduction

MiniTorch Module 1

This assignment requires the following files from the previous assignments. You can get these by running

python sync_previous_module.py previous-module-dir current-module-dir

The files that will be synced are:

    minitorch/operators.py minitorch/module.py tests/test_module.py tests/test_operators.py project/run_manual.py

module-1's People

Contributors

sauravpanda avatar srush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

module-1's Issues

autograd fail when setup

when I push my answer, It will raise error:

๐Ÿ“ Setup
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
  Collecting flake[8](https://github.com/minitorch/minitorch-module-1-gamdwk/actions/runs/7295821833/job/19882743013#step:3:9)==5.0.4
    Downloading flake8-5.0.4-py2.py3-none-any.whl (61 kB)
       โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 61.[9](https://github.com/minitorch/minitorch-module-1-gamdwk/actions/runs/7295821833/job/19882743013#step:3:10)/61.9 KB 3.4 MB/s eta 0:00:00
  Collecting pyflakes<2.6.0,>=2.5.0
    Downloading pyflakes-2.5.0-py2.py3-none-any.whl (66 kB)
       โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 66.1/66.1 KB 8.0 MB/s eta 0:00:00
  Collecting pycodestyle<2.[10](https://github.com/minitorch/minitorch-module-1-gamdwk/actions/runs/7295821833/job/19882743013#step:3:11).0,>=2.9.0
    Downloading pycodestyle-2.9.1-py2.py3-none-any.whl (41 kB)
       โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 41.5/41.5 KB 11.0 MB/s eta 0:00:00
  Collecting mccabe<0.8.0,>=0.7.0
    Downloading mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB)
  Installing collected packages: pyflakes, pycodestyle, mccabe, flake8
  Successfully installed flake8-5.0.4 mccabe-0.7.0 pycodestyle-2.9.1 pyflakes-2.5.0
  WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
  
  /usr/local/lib/python3.10/dist-packages/numpy/__init__.pyi:642: error: Positional-only parameters are only supported in Python 3.8 and greater
  Found 1 error in 1 file (errors prevented further checking)

I have never had such a problem on my local computer.
Why does Python 3.10 not support the 3.8 feature? How should I locate this error?
By the way, the isort for pre-commit should update to version 5.12.0, otherwise, an error will occur during submission. Please make the necessary changes.

Bug Report: some thing in class LT(ScalarFunction)

So sorry to bother you.

Thanks for your nice code and tutorial, I really benefited a lot after finish module-1. But some thing seems to be wrong with the Class LT. It does not define a backward function, but the method will be tested in task1_4. Am i correct? Or am I misunderstanding something? Thank you so much.

class LT(ScalarFunction):
    "Less-than function :math:`f(x) =` 1.0 if x is less than y else 0.0"

    @staticmethod
    def forward(ctx, a, b):
        # TODO: Implement for Task 1.2.
        raise NotImplementedError('Need to implement for Task 1.2')
        # TODO: Implement for Task 1.2.
        raise NotImplementedError('Need to implement for Task 1.2')
        # TODO: Implement for Task 1.4.
        raise NotImplementedError('Need to implement for Task 1.4')

Alternate solution for Task 1.2 does not pass tests

For Task 1.2, I believe the intended code for scalar.Scalar.__sub__is return Add.apply(self, -b), which passes the tests. Interestingly, if return Add.apply(self, Neg.apply(b)) is used, the tests that involve subtracting constants fail. Excerpt of the failed test cases below:

===============================short test summary info==============================
FAILED tests/test_scalar.py::test_one_args[fn4] - AssertionError: Expected return typ <class 'float'> got <class 'int'>: -200
FAILED tests/test_scalar.py::test_one_args[fn5] - AssertionError: Expected return typ <class 'float'> got <class 'int'>: -200
FAILED tests/test_scalar.py::test_one_args[fn13] - AssertionError: Expected return typ <class 'float'> got <class 'int'>: -5     

I've slightly modified the error message in autodiff.FunctionBase to print the offending value in question, and they are all ints. The root cause is due to scalar.ScalarFunction.data_type being hard-coded as float. I assume data_type is fixed for a reason, and there probably isn't an easy fix to allow the alternate solution to pass the tests. Just thought y'all should know.

(doc) Small typo in instructions

cp ../Module-0/operators.py ../Module-0/module.py minitorch/

should be replaced with:

cp ../Module-0/minitorch/operators.py ../Module-0/minitorch/module.py minitorch/

(doc) Questions on back-propagation algorithm

Initialize a queue with the final variable+derivative.
While the queue is not empty, pull a variable+derivative from the queue.
If the variable is a leaf then add its final derivative (_add_deriv) and loop to (1).
If the variables is not a leaf call .chain_rule on the last function that created it with derivative as ๐‘‘๐‘œ๐‘ข๐‘ก.
Loop through all the variables+derivative produced by the chain rule.
If the variable is in the queue (check .name), add to its current derivativ
Otherwise, add to the queue.

Actually, it's not necessary to Loop through all the variables+derivative produced by the chain rule. Even though we don't check for repetition, the chain rule and sum rule will automatically accumulate the deriv to the leaf node.

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.