parameters: (y_true, y_pred, alpha=0.5, const=K.epsilon())
return_statement: return loss_val
docstring: Tversky Loss.
      
      tversky(y_true, y_pred, alpha=0.5, const=K.epsilon())
      
      ----------
      Hashemi, S.R., Salehi, S.S.M., Erdogmus, D., Prabhu, S.P., Warfield, S.K. and Gholipour, A., 2018. 
      Tversky as a loss function for highly unbalanced image segmentation using 3d fully convolutional deep networks. 
      arXiv preprint arXiv:1803.11078.
      
      Input
      ----------
          alpha: tunable parameter within [0, 1]. Alpha handles imbalance classification cases.
          const: a constant that smooths the loss gradient and reduces numerical instabilities.
docstring_summary: Tversky Loss.
      
      tversky(y_true, y_pred, alpha=0.5, const=K.epsilon())
      
      ----------
      Hashemi, S.R., Salehi, S.S.M., Erdogmus, D., Prabhu, S.P., Warfield, S.K. and Gholipour, A., 2018. 
      Tversky as a loss function for highly unbalanced image segmentation using 3d fully convolutional deep networks. 
      arXiv preprint arXiv:1803.11078.
      
      Input
      ----------
          alpha: tunable parameter within [0, 1]. Alpha handles imbalance classification cases.
          const: a constant that smooths the loss gradient and reduces numerical instabilities.
docstring_tokens: Tversky Loss . tversky ( y_true y_pred alpha = 0 . 5 const = K . epsilon () ) ---------- Hashemi S . R . Salehi S . S . M . Erdogmus D . Prabhu S . P . Warfield S . K . and Gholipour A . 2018 . Tversky as a loss function for highly unbalanced image segmentation using 3d fully convolutional deep networks . arXiv preprint arXiv : 1803 . 11078 . Input ---------- alpha : tunable parameter within [ 0 1 ] . Alpha handles imbalance classification cases . const : a constant that smooths the loss gradient and reduces numerical instabilities .
function: def tversky(y_true, y_pred, alpha=0.5, const=K.epsilon()):
      '''
      Tversky Loss.
      
      tversky(y_true, y_pred, alpha=0.5, const=K.epsilon())
      
      ----------
      Hashemi, S.R., Salehi, S.S.M., Erdogmus, D., Prabhu, S.P., Warfield, S.K. and Gholipour, A., 2018. 
      Tversky as a loss function for highly unbalanced image segmentation using 3d fully convolutional deep networks. 
      arXiv preprint arXiv:1803.11078.
      
      Input
      ----------
          alpha: tunable parameter within [0, 1]. Alpha handles imbalance classification cases.
          const: a constant that smooths the loss gradient and reduces numerical instabilities.
          
      '''
      # tf tensor casting
      y_pred = tf.convert_to_tensor(y_pred)
      y_true = tf.cast(y_true, y_pred.dtype)
      
      # <--- squeeze-out length-1 dimensions.
      y_pred = tf.squeeze(y_pred)
      y_true = tf.squeeze(y_true)
      
      loss_val = 1 - tversky_coef(y_true, y_pred, alpha=alpha, const=const)
      
      return loss_val
function_tokens: def tversky ( y_true , y_pred , alpha = 0.5 , const = K . epsilon ( ) ) : # tf tensor casting y_pred = tf . convert_to_tensor ( y_pred ) y_true = tf . cast ( y_true , y_pred . dtype ) # <--- squeeze-out length-1 dimensions. y_pred = tf . squeeze ( y_pred ) y_true = tf . squeeze ( y_true ) loss_val = 1 - tversky_coef ( y_true , y_pred , alpha = alpha , const = const ) return loss_val