Skip to content

Commit

Permalink
code duplication for norm
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffwoollard committed Sep 17, 2024
1 parent 6def1bf commit c0f2f83
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cryo_challenge/_map_to_map/map_to_map_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def get_distance_matrix(self, maps1, maps2, global_store_of_running_results):
return cost_matrix


def norm2(map1, map2):
return torch.norm(map1 - map2) ** 2


class L2DistanceNorm(MapToMapDistance):
"""L2 distance norm"""

Expand All @@ -103,7 +107,7 @@ def __init__(self, config):

@override
def get_distance(self, map1, map2):
return torch.norm(map1 - map2) ** 2
return norm2(map1, map2)


class L2DistanceNormLowMemory(MapToMapDistanceLowMemory):
Expand All @@ -114,7 +118,7 @@ def __init__(self, config):

@override
def compute_cost(self, map1, map2):
return torch.norm(map1 - map2) ** 2
return norm2(map1, map2)


def correlation(map1, map2):
Expand Down

0 comments on commit c0f2f83

Please sign in to comment.