3 ms·
> running training for 10 hrs only to have a validation loop fail because of a shape mismatch. I agree that tracking array shapes at build time could catch cer
by aix1 4y ago
> running training for 10 hrs only to have a validation loop fail because of a shape mismatch.
I agree that tracking array shapes at build time could catch certain classes of bugs (and I would love to have that capability). However, it's not as easy as it may seem. Consider the following example. It shows that even a simple slicing operation can change the number of array dimensions in ways that are only known at run time.
>>> def f(arr, elem):
... return arr[elem]
...
>>> arr=np.zeros((1, 1))
>>> f(arr, 0).shape
(1,)
>>> f(arr, ...).shape
(1, 1)
>>> f(arr, np.newaxis).shape
(1, 1, 1)