i'm confused with CoordConv
i read a paper which written by uber lab
https://medium.com/@Cambridge_Spark/coordconv-layer-deep-learning-e02d728c2311
they create a network named Coordconv,and in this coordconv they not only add two layer of meshgrid but also with a simple conv net.

it said through this way they add positional info to every pixel points?
2.so that after conv the pixel points still remain in same place as in original image?
and this is also working to add two layers of meshgrid to freature maps which draw from neural network?
how could Meshgrid help add positional info to the image?
Does this just simply added two layers which are the same size as the original image but is in[-1,1] meshgrid to original input image?

a big THANKS in advance!

About CoordConv
Here is the original paper which proposed the CoordConv layer: CoordConv paper.
I will try to convey my instinctive undersanding of this operation.
How AddCoords works
The way the information is added is by stacking (concatenating, to be more accurate) two new 2D tensors to the data. Those two channels are not multiplied together, therefore there is no meshgrid involved in this process.
Say we are at a specific layer of the network. The last convolution step produced 4 2D-tensors of shape 8x8, each of which is the result of the previous convolution by a filter (thus we had 4 kernels in the previous step). They are in reality stacked in a single tensor of size bs * 8 * 8 * 4 where bs is the batch size, but let's ignore the batch size from now.
The AddCoords method will create two other 2D tensors:
xx_channel:
[[0, 0, 0, 0, 0, 0, 0, 0],
 [1, 1, 1, 1, 1, 1, 1, 1],
 [2, 2, 2, 2, 2, 2, 2, 2],
 [3, 3, 3, 3, 3, 3, 3, 3],
 [4, 4, 4, 4, 4, 4, 4, 4],
 [5, 5, 5, 5, 5, 5, 5, 5],
 [6, 6, 6, 6, 6, 6, 6, 6],
 [7, 7, 7, 7, 7, 7, 7, 7]]

and yy_channel:
[[0, 1, 2, 3, 4, 5, 6, 7],
 [0, 1, 2, 3, 4, 5, 6, 7],
 [0, 1, 2, 3, 4, 5, 6, 7],
 [0, 1, 2, 3, 4, 5, 6, 7],
 [0, 1, 2, 3, 4, 5, 6, 7],
 [0, 1, 2, 3, 4, 5, 6, 7],
 [0, 1, 2, 3, 4, 5, 6, 7],
 [0, 1, 2, 3, 4, 5, 6, 7]]    

Those are the results of the matmuls of the tf.range by the tf.ones.
They will then be scaled to fit in the range [-1, 1] and casted to tensorflow.float32 type:
xx_channel:
[[-1.        , -1.        , -1.        , -1.        , -1.        , -1.        , -1.        , -1.        ],
 [-0.71428571, -0.71428571, -0.71428571, -0.71428571, -0.71428571, -0.71428571, -0.71428571, -0.71428571],
 [-0.42857143, -0.42857143, -0.42857143, -0.42857143, -0.42857143, -0.42857143, -0.42857143, -0.42857143],
 [-0.14285714, -0.14285714, -0.14285714, -0.14285714, -0.14285714, -0.14285714, -0.14285714, -0.14285714],
 [ 0.14285714,  0.14285714,  0.14285714,  0.14285714,  0.14285714,  0.14285714,  0.14285714,  0.14285714],
 [ 0.42857143,  0.42857143,  0.42857143,  0.42857143,  0.42857143,  0.42857143,  0.42857143,  0.42857143],
 [ 0.71428571,  0.71428571,  0.71428571,  0.71428571,  0.71428571,  0.71428571,  0.71428571,  0.71428571],
 [ 1.        ,  1.        ,  1.        ,  1.        ,  1.        ,  1.        ,  1.        ,  1.        ]]

yy_channel:
[[-1., -0.71428571, -0.42857143, -0.14285714,  0.14285714, 0.42857143,  0.71428571,  1.],
 [-1., -0.71428571, -0.42857143, -0.14285714,  0.14285714, 0.42857143,  0.71428571,  1.],
 [-1., -0.71428571, -0.42857143, -0.14285714,  0.14285714, 0.42857143,  0.71428571,  1.],
 [-1., -0.71428571, -0.42857143, -0.14285714,  0.14285714, 0.42857143,  0.71428571,  1.],
 [-1., -0.71428571, -0.42857143, -0.14285714,  0.14285714, 0.42857143,  0.71428571,  1.],
 [-1., -0.71428571, -0.42857143, -0.14285714,  0.14285714, 0.42857143,  0.71428571,  1.],
 [-1., -0.71428571, -0.42857143, -0.14285714,  0.14285714, 0.42857143,  0.71428571,  1.],
 [-1., -0.71428571, -0.42857143, -0.14285714,  0.14285714, 0.42857143,  0.71428571,  1.]]

They will then be concatenated to the other 2D-tensors along the last dimension (&quot;-1&quot;), ending up with a 3D-tensor with shape 8 * 8 * 6(again, the dimension of the batch size is ignored in my explanation).
Those two generated channels are what the authors in the paper call coordinate informations. The method literally adds the coordinates of each 2D position : the y-coord and the x-coord.
In our example, let's consider the values of an input tensor at position [4, 5],  meaning the values along the last dimension (size 4), which is accessible like this : input_tensor[4, 5, :]. It may return something like this :
input_tensor[4, 5, :]
# &gt; [0.75261177, 0.62114716, 0.76845441, 0.44747785]

After AddCoords, it becomes:
ret[4, 5, :]
# &gt; [0.75261177, 0.62114716, 0.76845441, 0.44747785, 0.14285714, 0.42857143]

... where 0.14285714 is the scaled value of 4 ie its y-coord and 0.42857143 is the scaled value of 5 ie its x-coord. The information about coordinates is now contained inside the resulting tensor, which is returned by the AddCoords method.
The CoordConv
It's a designed layer that applies AddCoords to the input and feeds the resulting tensor to a classic Conv2D layer. As such, it can be added to a neural network, as you would do with a Conv2D layer.
That's what the authors did, when experimenting with GANs for example, where they substitued Conv2D with CoordConv (which, again, includes a Conv2D).
Let me know if that answers your questions and/or correct any misconceptions.
What does it imply for the neural network ?
More trainable parameters...
Let's give a bit more context to our previous example.
In our previous example, the last layer yielded a tensor with shape 8 x 8 x 4. Let's say we want the next convolution layer to yield 16 output filters, from a convolution window of 3 * 3.

You can see this link to get what convolution does mathematically ,
chapter 2.1 . You can get a basic understanding of what the
convolution operation yields thanks to this visualizer. Just keep
in mind both links show a single kernel and a single channel input
matrix.


If we don't add the coordinate tensors, the convolution to come will have 16 kernels with shape 3 x 3 x 4 each.
If we do apply AddCoords, we will feed a tensor with shape 8 x 8 x 6 instead, and our 16 kernels will each have the shape 3 x 3 x 6.

You can think of those kernels as neurons. Each neuron has 3 x 3 x 4 == 36  weights (Conv2D) or 3 x 3 x 6 == 54 weights (AddCoords+Conv2D, or CoordConv). Their weights will be updated during the learning process. Knowing this, it should appear evident that the coordinates channels of CoordConv implies new and specific weights to each kernel of the convolution layer. That's how the neural network takes into consideration these coordinates.
... implied in similar training processes
If you haven't been experimenting with Machine Learning, the supervised learning process of a neural network might be quite complex to comprehend, but it's more general and could be resumed (oversimplified) as:

We calculate the error, which is a mathematical way to describe how
far the prediction is from the ground truth. Then we update (add)
each parameter (or weight) in the network, layer after layer from the
output layer to the input one, by a value that represents its
implication in this error and the direction it should take to decrease the error. This process is called &quot;backpropagation of
the error&quot;.

