Code QuizIntermediate Converting HWC to NCHW
Spot the transpose bug when reshaping an image tensor for a model.
Codepython
import numpy as np
# img shape is (H, W, C); model wants NCHW
tensor = img.transpose(2, 1, 0)
tensor = tensor[np.newaxis, ...] # add batch
print(tensor.shape)
What is the bug in this HWC-to-NCHW conversion?