From 51447e4227bb7d92355589eb7ae553599b6e3047 Mon Sep 17 00:00:00 2001 From: qwertpi Date: Tue, 16 Apr 2019 07:35:01 +0100 Subject: [PATCH 1/4] Fixed indentation error (that I had caused) --- keract/keract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keract/keract.py b/keract/keract.py index fe7c836..ca1d5bb 100644 --- a/keract/keract.py +++ b/keract/keract.py @@ -201,5 +201,5 @@ def display_gradients_of_trainable_weights(gradients, save=False): plt.savefig(layer_name.split('/')[0] + '.png', bbox_inches='tight') else: plt.show() - plt.close(fig) + plt.close(fig) From 1ef98d89a3a6355432dd87ab250291dab192dfe4 Mon Sep 17 00:00:00 2001 From: qwertpi Date: Tue, 16 Apr 2019 08:00:23 +0100 Subject: [PATCH 2/4] Fixed heatmap code that was broken during an update by another user Also renamed a variable to prevent confusion and breakages arising again --- keract/keract.py | 1 - 1 file changed, 1 deletion(-) diff --git a/keract/keract.py b/keract/keract.py index ca1d5bb..787447c 100644 --- a/keract/keract.py +++ b/keract/keract.py @@ -202,4 +202,3 @@ def display_gradients_of_trainable_weights(gradients, save=False): else: plt.show() plt.close(fig) - From 253bb6ef27de0f4eac909fdbf29d6011047d037f Mon Sep 17 00:00:00 2001 From: qwertpi Date: Wed, 17 Apr 2019 07:52:38 +0100 Subject: [PATCH 3/4] Actually modified some things --- keract/keract.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/keract/keract.py b/keract/keract.py index 787447c..14e4a04 100644 --- a/keract/keract.py +++ b/keract/keract.py @@ -121,11 +121,11 @@ def display_activations(activations, cmap=None, save=False): plt.close(fig) -def display_heatmaps(activations, image, save=False): +def display_heatmaps(activations, input_image, save=False): """ Plot heatmaps of activations for all filters overlayed on the input image for each layer :param activations: dict mapping layers to corresponding activations (1, output_h, output_w, num_filters) - :param image: input image for the overlay + :param input_image: input image for the overlay :param save: bool- if the plot should be saved :return: None """ @@ -155,11 +155,11 @@ def display_heatmaps(activations, image, save=False): img = acts[0, :, :, i] # scale the activations (which will form our heat map) to be in range 0-1 img = scaler.transform(img) - # resize heatmap to be same dimensions of image + # resize heatmap to be same dimensions of input_image img = Image.fromarray(img) - img = img.resize((image.shape[0], image.shape[1]), Image.BILINEAR) + img = img.resize((input_image.shape[0], input_image.shape[1]), Image.BILINEAR) img = np.array(img) - axes.flat[i].imshow(img / 255.0) + axes.flat[i].imshow(input_image / 255.0) # overlay a 70% transparent heat map onto the image # Lowest activations are dark, highest are dark red, mid are yellow axes.flat[i].imshow(img, alpha=0.3, cmap='jet', interpolation='bilinear') From 61d464a66112035c683d060a84ae3c4d7a06629e Mon Sep 17 00:00:00 2001 From: qwertpi Date: Wed, 17 Apr 2019 07:55:30 +0100 Subject: [PATCH 4/4] Removed extraneous new line