Code Monkey home page Code Monkey logo

module-3's Introduction

MiniTorch Module 3

You will need to modify tensor_functions.py slightly in this assignment.

  • Tests:
python run_tests.py
  • Note:

Several of the tests for this assignment will only run if you are on a GPU machine and will not run on github's test infrastructure. Please follow the instructions to setup up a colab machine to run these tests.

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/tensor_data.py minitorch/tensor_functions.py minitorch/tensor_ops.py minitorch/operators.py minitorch/module.py minitorch/autodiff.py minitorch/module.py project/run_manual.py project/run_scalar.py project/run_tensor.py

module-3's People

Contributors

g-u-n avatar srush avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

module-3's Issues

return value of backward in class Sum

From my perspective, the shape of 'grad_output' should be broadcasted into a_shape.
Although it can still pass task3_1, I'm not sure of its accuracy in more complex situations.

            @staticmethod
            def backward(ctx, grad_output):
                a_shape, dim = ctx.saved_values
              
                if dim is None:
                    out = grad_output.zeros(a_shape)
                    out._tensor._storage[:] = grad_output[0]
                    return out
                else:
                # START Code Update
                    return grad_output #should be replaced by add_zip(grad_output,zeros(a_shape)) #
                # END Code Update

Wrong test target for 3.2?

Hi,

Thanks for creating this absolutely awesome learning resource!

For context, I'm passing all tests up to and including the task3_1 set.

I've been stuck on 3.2 for a while, and thought I'd double check the "ground truth" for matmul tests marked task3_2 (i.e. the values stored in c2). However, printing the expected results out and then computing them separately with numpy give different results.

[
	[
		[0.6272 0.3107 0.0176]
		[0.8124 0.4486 0.9398]]] @
[
	[
		[0.6620 0.4447 0.7729 0.1804]
		[0.8839 0.0619 0.2097 0.8598]
		[0.7512 0.8540 0.1345 0.8480]]] =

[
	[0.8249 0.8901 0.2055 1.2106]
	[0.8249 0.8901 0.2055 1.2106]]
>>> import numpy as np
>>> np.array([[[0.6272, 0.3107, 0.0176], [0.8124, 0.4486, 0.9398]]]) @ np.array([[[0.6620, 0.4447, 0.7729, 0.1804], [0.8839, 0.0619, 0.2097, 0.8598], [0.7512, 0.8540, 0.1345, 0.8480]]])
array([[[0.70305525, 0.31317857, 0.55228387, 0.39521154],
        [1.6403041 , 1.19163182, 0.84837848, 1.32921364]]])
[
	[
		[0.0000 0.0000]
		[0.0000 0.0000]]
	[
		[0.0000 0.0000]
		[0.0000 0.1000]]] @ 
[
	[
		[0.0000 0.0000]
		[0.0000 0.1000]]] =

[
	[
		[0.0000 0.0000]
		[0.0000 0.0100]]
	[
		[0.0000 0.0000]
		[0.0000 0.0100]]]
>>> import numpy as np
>>> np.array([[[0.0000, 0.0000], [0.0000, 0.0000]],	[[0.0000, 0.0000], [0.0000, 0.1000]]]) @ np.array([[[0.0000, 0.0000],[0.0000, 0.1000]]])
array([[[0.  , 0.  ],
        [0.  , 0.  ]],

       [[0.  , 0.  ],
        [0.  , 0.01]]])

So I'm writing this because I'm wondering whether:

  1. tests prior to 3.2 failed to catch some bug which messes up the "ground truth" target for me personally, or
  2. tests for 3.2 are buggy

Do you have any thoughts on this?

Thanks again for putting together this masterpiece.

Edit: Also, skipping to run_fast_tensor.py with cpu backend seems to work (i.e. training takes place, loss goes down, metrics go up), so I'll just ignore the two failing tests for now until I run into seemingly related issues. Next, CUDA!

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.