def test_dice_coef_max(self):
     """Test the upper-bound of the dice coefficient."""
     y_true = np.ones((2, 1, 200, 200))
     y_pred = np.ones((2, 1, 200, 200))
     var_y_true = K.variable(y_true)
     var_y_pred = K.variable(y_pred)
     out_loss = gm_model.dice_coef(var_y_true, var_y_pred)
     res = K.eval(out_loss)
     assert res == 1.0
 def test_dice_coef_max(self):
     """Test the upper-bound of the dice coefficient."""
     y_true = np.ones((2, 1, 200, 200))
     y_pred = np.ones((2, 1, 200, 200))
     var_y_true = K.variable(y_true)
     var_y_pred = K.variable(y_pred)
     out_loss = gm_model.dice_coef(var_y_true, var_y_pred)
     res = K.eval(out_loss)
     assert res == 1.0
 def test_dice_coef_min(self):
     """Test the lower-bound of the dice coefficient."""
     y_true = np.ones((2, 1, 200, 200))
     y_pred = np.zeros((2, 1, 200, 200))
     var_y_true = K.variable(y_true)
     var_y_pred = K.variable(y_pred)
     out_loss = gm_model.dice_coef(var_y_true, var_y_pred)
     res = K.eval(out_loss)
     # Smoothing term makes it never reach zero
     assert res == pytest.approx(0.0, 0.001)
 def test_dice_coef_min(self):
     """Test the lower-bound of the dice coefficient."""
     y_true = np.ones((2, 1, 200, 200))
     y_pred = np.zeros((2, 1, 200, 200))
     var_y_true = K.variable(y_true)
     var_y_pred = K.variable(y_pred)
     out_loss = gm_model.dice_coef(var_y_true, var_y_pred)
     res = K.eval(out_loss)
     # Smoothing term makes it never reach zero
     assert res == pytest.approx(0.0, abs=0.001)