I’ve looked all over the internet but using reshape to add a dimension doesn’t seem to allow specifying the shape of that dimension and adding dummy values as required.
I’ve looked at the official documentation and searched StackExchange etc…
I was trying to add an additional dimension of size 28, initialized all to zeroes. The instructions say “Reshape the images to add an extra dimension”
Here you go:
>>> import numpy as np
>>> a = np.random.random((3,4))
>>> a.shape
(3, 4)
>>> a.reshape((3,4,1)).shape
(3, 4, 1)
>>>
1 Like