Question: I want to use the histogram of the output from a CNN to compute the loss. I am wondering whether `tf.histogram_fixed_width()` supports the gradient to flow back to its former layer. Only it works, I can add a loss layer after calculating the histogram.

Answer: 
`tf.histogram_fixed_width()` does not support autogradient functionality since histogram is not a continuous differential function. You can look at the following example which returns gradient None.

```
import keras.backend as K
import tensorflow as tf

value_range = [0.0, 5.0]
a = np.array([-1.0, 0.0, 1.5, 2.0, 5.0, 15])

x = K.variable(a)
hist = tf.histogram_fixed_width(x, value_range, nbins=5, dtype=tf.float32)
gradient = K.gradients(hist, x)

# output is [None]

```
I had the similar problem. There are two ways you can try: 1. After the output layer, add an extra layer to produce the histogram; 2. Use something like `tf.RegisterGradient` or `tf.custom_gradient` to define your own gradients for the operations.