def huber( targetReal, targetInft, predReal, predInft, delta=1.0 ): diff = td.subtract( targetReal, targetInft, predReal, predInft ) ltd = td.multiply( *td.subtract( *diff, 0.5 * delta, 0.0 ), delta, 0.0 ) full = td.multiply( *td.power( *diff, 2.0, 0.0 ), 0.5, 0.0 ) return td.where( tf.greater( diff[ 0 ], delta ), *ltd, *full )
def mse( targetReal, targetInft, predReal, predInft ): diff = td.subtract( targetReal, targetInft, predReal, predInft ) return td.power( *diff, 2.0, 0.0 )