There is a multi-dimensional array, e.g., data is of shape (1,320,320,1)

I once saw a function which uses

x=data[:,c:-c,d:-d]

I am not very clear about what does this mean, my original understanding is that x will keep data's first two dimensions, and take a slice from data on the third and fouth dimension. But when c=0,d=0. The resulting x is of shape (1,0,0,1). I am confused about this. Thanks.

I am not very clear about what does this mean, my original understanding is that x will keep data's first two dimensions, and take a slice from data on the third and fouth dimension.

It keeps the first and fourth dimension and slices the two inbetween.

x=data[:,c:-c,d:-d]

The first dimension is unchanged. If c=d=0, then the second and third dimension is between 0 and 0-1=-1. So no item is selected.
The last one is not mentioned, so it stays unchanged.

The same behaviour on a one dimensional python array (list):

>>> data=list(range(10))
>>> c=0
>>> data[c:-c]
[]
>>> c=2
>>> data[c:-c]
[2, 3, 4, 5, 6, 7]
>>>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.