From d39a843ef9e232edc676712c695cab536df199e2 Mon Sep 17 00:00:00 2001 From: aodhneine Date: Sun, 15 Nov 2020 21:51:56 +0000 Subject: [PATCH] Add utility tensor function --- pygrad/tensor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pygrad/tensor.py b/pygrad/tensor.py index b424390..21097b7 100644 --- a/pygrad/tensor.py +++ b/pygrad/tensor.py @@ -1,8 +1,13 @@ import numpy as np +def tensor(*args, **kwargs): + return Tensor(*args, **kwargs) + class Tensor: # TODO Implement 'requires_grad' functionality. def __init__(self, value): + # NOTE We technically could support both numpy arrays and scalar values, + # but it is too much work. if not isinstance(value, np.ndarray): print(f"{type(value)} is not compatible with {np.ndarray}") exit(-1)