From 538b1d7f5bdd04a70536997afba22cec033eefd0 Mon Sep 17 00:00:00 2001 From: Faisal Memon Date: Mon, 9 Jan 2023 18:08:05 +0000 Subject: [PATCH] Print out the tensor using numpy(). (#454) This commit resolves issue https://github.com/geohot/tinygrad/issues/453 In the example code in the README.md, when it is run, it prints for Tiny Grad the tensors as: with grad None> with grad None> But to be equivalent to the output of the Torch example, we need to use numpy() to get it to show: [[ 2. 2. 2.] [ 0. 0. 0.] [-2. -2. -2.]] [[1. 1. 1.]] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e479f2342..291416c3b4 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ y = Tensor([[2.0,0,-2.0]], requires_grad=True) z = y.matmul(x).sum() z.backward() -print(x.grad) # dz/dx -print(y.grad) # dz/dy +print(x.grad.numpy()) # dz/dx +print(y.grad.numpy()) # dz/dy ``` ### Same example in torch