Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Generated when running Sample Program #3

Open
Aadit-Ambadkar opened this issue May 2, 2024 · 1 comment
Open

Error Generated when running Sample Program #3

Aadit-Ambadkar opened this issue May 2, 2024 · 1 comment
Assignees

Comments

@Aadit-Ambadkar
Copy link

Aadit-Ambadkar commented May 2, 2024

Tested this on a fresh conda environment with just neuralforge installed (and its dependencies) and it generates some errors:

import neuralforge as forge

# Instantiate Tensors:
x = forge.randn((8,4,5))
w = forge.randn((8,5,4), requires_grad = True)
b = forge.randint((4), requires_grad = True)


# Make calculations:
out = x @ w
out += b

# Compute gradients on whole graph:
out.backward()

# Get gradients from specific Tensors:
print(w.grad)
print(b.grad)
Traceback (most recent call last):
  File "/Users/.../autograd_np.py", line 14, in <module>
    out.backward()
  File "/opt/miniconda3/envs/.../neuralforge/tensor_operations.py", line 49, in backward
    self.operation.backward(self.grad, self)
  File "/opt/miniconda3/envs/.../neuralforge/tensor_operations.py", line 273, in backward
    b.backward(db, z)
  File "/opt/miniconda3/envs/.../neuralforge/tensor_operations.py", line 42, in backward
    self.grad += grad
numpy.core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'add' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

Not entirely sure how to fix this as it seems like a neuralforge issue and not a my-code issue. I even tried changing the dtype of b._data to float64 (b._data = b._data.astype("float64")) and it still generates the same errors

@eduardoleao052
Copy link
Owner

Thanks for letting me know! I'll get into it rn

@eduardoleao052 eduardoleao052 self-assigned this May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants