Map and slice don't preserve the size of an array

Try this instead:

mapslices(x -> rand(3,4).*x, rand(1,3,4), dims=[2,3])
2 Likes