I have an array of shape (128, 36, 8)
and I'd like to find the number of occurrences of the unique subarrays of length 8 in the last dimension.
I'm aware of np.unique
and np.bincount
, but those seem to be for elements rather than subarrays. I've seen this question but it's about finding the first occurrence of a particular subarray, rather than the counts of all unique subarrays.
The question states that the input array is of shape
(128, 36, 8)
and we are interested in finding unique subarrays of length8
in the last dimension. So, I am assuming that the uniqueness is along the first two dimensions being merged together. Let us assumeA
as the input 3D array.Get the number of unique subarrays
Sample run -
Get the count of occurrences of unique subarrays
Sample run -