Inverse Function Of Numpy As_strided
I have a 4-tensor x. The 6-tensor y is computed as follows: x = np.random.randn(64, 28, 28, 1) strided_shape = 64, 26, 26, 3, 3, 1 y = numpy.lib.stride_tricks.as_strided(x, strided
Solution 1:
Well y
is simply a view into x
, with different shape and strides. As such, recovering x
from y
is simply changing back the shape and strides. So, given those (assuming those are saved before the x
to y
conversion), it would be simply -
x = np.lib.stride_tricks.as_strided(y, x.shape, x.strides)
Post a Comment for "Inverse Function Of Numpy As_strided"