FlorentF9 / DeepTemporalClustering

:chart_with_upwards_trend: Keras implementation of the Deep Temporal Clustering (DTC) model
MIT License
219 stars 58 forks source link

Heatmap #12

Closed chen-ya-ling closed 3 years ago

chen-ya-ling commented 3 years ago

Hello, how can I see the generated heatmap? I set --heapmap to true, but I don't see the generated heatmap.

FlorentF9 commented 3 years ago

Hi, you can output the heatmap using the predict_heatmapmethod of the DTC class, defined here: https://github.com/FlorentF9/DeepTemporalClustering/blob/master/DeepTemporalClustering.py#L277

You have to build the model and train it (or load weights) in a script beforehand. However I warn you that I did not manage to get satisfying results (the paper does not provided much details on the implementation and training of the heatmap network). Tell me if you achieve something :smiley:

BEbillionaireUSD commented 3 years ago

Hi, Could you please explain more about that? From the predict_map I can get an array with shape (samples, times, clusters), right?

How can I generate a heatmap? Which vector can be used to plot? For a heatmap, I need a n*n matrix.

FlorentF9 commented 3 years ago

The heatmap is what is called an "activation map" or "saliency map", often used in computer vision. It indicates how much each dimension of the input - here the dimension is time - contributes to each class or cluster. Basically, the heatmap network is a classifier, where element (i, t, c) of the heatmap represents how much time t of input i contributes to being classified in cluster c. The values are activations of a convolution layer, so these are not probabilities. Probabilities are obtained later, after applying a GAP (global average pooling) on time dimension + a softmax normalization.