Imagine a situation in which my neural network takes coordinates of the planets at some time *t*, and outputs coordinates at a time *t*+Δ*t*. Due to the nature of my simulation which I am using to train this network, it’s much more convenient to compare distances of one fixed planet to all others than directly all coordinates which is why in a loss function I would like to have a term like

**L** = sum_over_batch [ (Distances_by_model - Distances_by_ground_truth)**2 ]

Just to make clear, distance is a function of **coordinates of planets** which maps an array of coordinates of shape (N_planets,3) to a vector (N_planets,1).

Finally, my question is: since my NN outputs coordinates, and not distances, but I have distances in a loss functions, do I have to implement autograd distance function? If not, could you name an example in which I would have to implement it?

Thanks in advance,

confused physics student