CoreMLHelpers icon indicating copy to clipboard operation
CoreMLHelpers copied to clipboard

How to use the transposed function? from (26, 64, 48, 1) to (1, 26, 64, 48)

Open yonatanbitton opened this issue 3 years ago • 3 comments

Hello I have an MLMultiArray in shape (1, 64, 48, 26) that I need to transpose to shape (1, 26, 64, 48). How can I do it?

Equivalent python code:

import numpy as np
arr = np.zeros(1*64*48*26).reshape((1, 64, 48, 26))
arr_transposed = arr.transpose((0,3,1,2))

Thanks

yonatanbitton avatar Apr 12 '21 12:04 yonatanbitton

It's already in the correct shape. You can ignore a dimension that is 1.

hollance avatar Apr 12 '21 15:04 hollance

Sorry - I ment from (1, 64, 48, 26) to (1, 26, 64, 48). I updated the post.

yonatanbitton avatar Apr 12 '21 16:04 yonatanbitton

Easiest way is to add a transpose / permute layer to the model at the end.

hollance avatar Apr 12 '21 19:04 hollance