class_docstr: This code was developed by jbpatel@mit.edu.
      
class_docstr_tok: ["This","code","was","developed","by","jbpatel","@","mit.edu","."]
code: def distTransErrorMatrix(self, y_true_onehot, y_dist, y_pred_max_mat):
      from keras import backend as K
      from keras.layers import Lambda, multiply, add, subtract
  
      y_p1 = Lambda((lambda arg: K.cast(arg[..., 1], K.floatx())))(
          y_pred_max_mat
      )
      y_t0 = Lambda((lambda arg: K.cast(arg[..., 0], K.floatx())))(
          y_true_onehot
      )
      y_t1 = Lambda((lambda arg: K.cast(arg[..., 1], K.floatx())))(
          y_true_onehot
      )
      y_d = Lambda((lambda arg: K.cast(arg[..., 0], K.floatx())))(
          y_dist
      )
  
      # squash, invert distance map, multiply/exponentiate by some factor
      factor = 2.0
      currMin = 1.0 / (factor + 1.0)
      currMax = 1.0
      newMin = 1.0
      newMax = currMin
      y_d_squashed = Lambda(
          lambda arg: (
              arg / (arg + (factor * K.ones_like(arg)) + K.epsilon())
          )
      )(y_d)
      y_d_invert = Lambda(
          lambda arg: (
              (
                  ((newMax - newMin) * (arg - currMin))
                  / (currMax - currMin)
              )
              + newMin
          )
      )(y_d_squashed)
      y_d = Lambda(lambda arg: (arg * (factor + 1.0)))(y_d_invert)
  
      # Interior error
      multLayer = multiply([y_t1, y_p1])
      subtractLayer = subtract([y_t1, multLayer])
      interiorError = multiply([y_d, subtractLayer])
  
      # Exterior error
      multLayer2 = multiply([y_t0, y_p1])
      exteriorError = multiply([y_d, multLayer2])
  
      # Total error
      error = add([interiorError, exteriorError])
  
      # add one to error to ensure that aren't multiplying by zero
      error = Lambda(lambda arg: (K.ones_like(arg) + arg))(error)
      return error
  
imports: import numpy
  import itertools
label_desc: Use image node_id 10 for calling the WeightedCategoricalCrossEntropy obj's underlying member method code with example usage: obj.distTransErrorMatrix(y_true_onehot, y_dist, y_pred_max_mat) and returns: error