Torch.histc with Variables

Hi, all
I want to calculate the histogram with Variables and find the torch.histc function. Unfortunately, this function does not support the Variables. Any alternatives?

Thanks

If you don’t need to backprop through the output of the histogram, you can call torch.histc on the tensor data of the variable. ie if x is your variable, you can get its tensor data via x.data.

Honestly, I want to use the histogram as the loss function, hence I need to call the histc on the variable

1 Like

Did you ever figure out how to do this? When I try to backpropagate through torch.histc tensor I am told “the derivative for “histc” is not implemented”

Same question. It seems like torch.histc() doesn’t have derivative function, and is not supposed to be a part of loss, or any part of computational graph. Maybe one could write his own histc() and implement the derivative, but in my opinion, it is hard with select operations inside of histc().