#NEWLINE# def total_variation_loss( x ) : #NEWLINE# #INDENT# assert ( K . ndim ( x ) == 4 ) #NEWLINE# a = K . square ( ( x [ : , : , : ( img_width - 1 ) , : ( img_height - 1 ) ] - x [ : , : , 1 : , : ( img_height - 1 ) ] ) ) #NEWLINE# b = K . square ( ( x [ : , : , : ( img_width - 1 ) , : ( img_height - 1 ) ] - x [ : , : , : ( img_width - 1 ) , 1 : ] ) ) #NEWLINE# return K . sum ( K . pow ( ( a + a ) , 1.25 ) )