我想使用 Hausdorff Distance 作为训练的度量,但我刚刚找到了 Weighted_Hausdorff_loss并将其用作医学图像分割的度量。
import math
import numpy as np
import tensorflow as tf
from sklearn.utils.extmath import cartesian
resized_height = 192
resized_width = 192
max_dist = math.sqrt(resized_height**2 + resized_width**2)
n_pixels = resized_height * resized_width
all_img_locations = tf.convert_to_tensor(cartesian([np.arange(resized_height), np.arange(resized_width)]),
tf.float32)
batch_size = 1
def tf_repeat(tensor, repeats):
"""
Args:
input: A Tensor. 1-D or higher.
repeats: A list. Number of repeat for each dimension, length must be the same as the number of dimensions in input
Returns:
A Tensor. …Run Code Online (Sandbox Code Playgroud)