I'd like to define a loss function in tensorflow based on a histogram but that requires the histogram function to support gradients, which is not the case. For example, using tf.histogram_fixed_width I get an error "No gradients provided for any variable, check your graph for ops that do not support gradients". I am hence looking for a work-around or an alternative function to compute histograms in tensorflow that supports gradients.