<p>A vanilla CNN is usually incapable of inferring that sort of spatial information without a bit of extra help. There have been numerous attempts to remedy that, one of which is <a href="https://arxiv.org/abs/1807.03247" rel="nofollow noreferrer">CoordConv</a>. The tl;dr is that in cases when you want to regress positions in an array like in your problem, it's useful to supply the network with a tensor/matrix/vector/whatever which contains (usually normalized) coordinates. You can do that either at input or at different levels. For example, in your case, your input could be modified to look like this:</p>

<pre><code>#Tensor of size 1x1x2x3100 
[0, ..., non_zero_val, 0, other_non_zero_val, 0, 0]
[0,  1 , ...                                  3099]/3099 #element-wise division just to normalise
</code></pre>
Is there any way where I can make a CNN output pixel locations?
<p>I want to train a CNN that takes as an input a numpy array of shape (1600, 800, 1) which would contain all 0s except at few pixels where I can have values from range 10 to 3100(This numpy array is not an image) and the output should be of size 310 where each element is a pair containing coordinates(x, y) positions of the points in the input that had non zero values.</p>

<p>Is there any way of doing this? Any insight on this is greatly appreciated. Thanks in advance!</p>