So it turns out that the problem lies in pairwise_distance attribute keepdim. Networks learn normally with the attribute set to default (False). I’ll dig into that and write why when I’ll have a moment.