Cropping tensor

#1

Hi,

I’ve a tensor of size N x 3 x 364 x364, where N is the number of images. I’d like to “center crop” the tensor to of size N x 3 x 256 x 256. What would be most efficient way to achieve this in cpp? (I’m not using opencv)

Currently I do the following:

batch = tensor of size N x 3 x 364 x 364;
tensor_sliceH = batch.slice(2, start_height, end_height);
tensor_sliceW = tensor_sliceH.slice(3, start_width, end_width);

Thanks! :slight_smile:

(Jin Tian) #2

I thin no good way to do this