jpdefrutos commited on
Commit
7a8ed91
·
1 Parent(s): e1a3fc2

Following TF deprecation warnings

Browse files
DeepDeformationMapRegistration/losses.py CHANGED
@@ -41,7 +41,7 @@ class HausdorffDistanceErosion:
41
  def _erode(self, in_tensor):
42
  indiv_channels = tf.split(in_tensor, self.im_shape[-1], -1)
43
  res = list()
44
- with tf.variable_scope('erode', reuse=tf.AUTO_REUSE):
45
  for ch in indiv_channels:
46
  res.append(self.conv(tf.expand_dims(ch, 0), self.kernel, [1] * (self.ndims + 2), 'SAME'))
47
  # out = -tf.nn.max_pool3d(-tf.expand_dims(in_tensor, 0), [3]*self.ndims, [1]*self.ndims, 'SAME', name='HDE_erosion')
@@ -790,7 +790,7 @@ class GeneralizedDICEScore:
790
 
791
  size_y_true = tf.reduce_sum(y_true, axis=1, name='GDICE_size_y_true')
792
  size_y_pred = tf.reduce_sum(y_pred, axis=1, name='GDICE_size_y_pred')
793
- w = tf.div_no_nan(1., tf.pow(size_y_true, 2), name='GDICE_weight')
794
  numerator = w * tf.reduce_sum(y_true * y_pred, axis=1)
795
  denominator = w * (size_y_true + size_y_pred)
796
  return tf.div_no_nan(2 * tf.reduce_sum(numerator, axis=-1), tf.reduce_sum(denominator, axis=-1))
 
41
  def _erode(self, in_tensor):
42
  indiv_channels = tf.split(in_tensor, self.im_shape[-1], -1)
43
  res = list()
44
+ with tf.compat.v1.variable_scope('erode', reuse=tf.AUTO_REUSE):
45
  for ch in indiv_channels:
46
  res.append(self.conv(tf.expand_dims(ch, 0), self.kernel, [1] * (self.ndims + 2), 'SAME'))
47
  # out = -tf.nn.max_pool3d(-tf.expand_dims(in_tensor, 0), [3]*self.ndims, [1]*self.ndims, 'SAME', name='HDE_erosion')
 
790
 
791
  size_y_true = tf.reduce_sum(y_true, axis=1, name='GDICE_size_y_true')
792
  size_y_pred = tf.reduce_sum(y_pred, axis=1, name='GDICE_size_y_pred')
793
+ w = tf.math.divide_no_nan(1., tf.pow(size_y_true, 2), name='GDICE_weight')
794
  numerator = w * tf.reduce_sum(y_true * y_pred, axis=1)
795
  denominator = w * (size_y_true + size_y_pred)
796
  return tf.div_no_nan(2 * tf.reduce_sum(numerator, axis=-1), tf.reduce_sum(denominator, axis=-1))