diff --git a/norch/tensor.py b/norch/tensor.py index 4a896b3..6548e9a 100644 --- a/norch/tensor.py +++ b/norch/tensor.py @@ -316,6 +316,8 @@ class Tensor: if isinstance(other, (int, float)): other = other * self.ones_like() + broadcasted_shape = [] + # Function to determine if broadcasting is needed and get the broadcasted shape def broadcast_shape(shape1, shape2): if shape1 == shape2: @@ -325,7 +327,6 @@ class Tensor: shape1 = [1] * (max_len - len(shape1)) + shape1 shape2 = [1] * (max_len - len(shape2)) + shape2 - broadcasted_shape = [] for dim1, dim2 in zip(shape1, shape2): if dim1 != dim2 and dim1 != 1 and dim2 != 1: raise ValueError("Shapes are not compatible for broadcasting") diff --git a/test.py b/test.py index 92d779d..3e45c78 100644 --- a/test.py +++ b/test.py @@ -9,7 +9,7 @@ W2 = norch.Tensor([[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]], requires_ B2 = norch.Tensor([[1, 2, 3, 4, 5]], requires_grad=True) -Z1 = W1 @ X + B1 +Z1 = W1 @ X - B1 # Perform matrix multiplication