From a89dfe6ba0168e7b42ae03ded1cdf0d4726020d9 Mon Sep 17 00:00:00 2001 From: Neta Zmora <neta.zmora@intel.com> Date: Mon, 27 Aug 2018 19:15:16 +0300 Subject: [PATCH] Jupyter notebook: Fix PyTorch 0.4 compatability issue when rendering Sometimes the gmin/gmax in group color-normalization ends up with a zero dimensional tensor, which needs to be accessed using .item() --- jupyter/alexnet_insights.ipynb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jupyter/alexnet_insights.ipynb b/jupyter/alexnet_insights.ipynb index bedaaf0..fec514b 100644 --- a/jupyter/alexnet_insights.ipynb +++ b/jupyter/alexnet_insights.ipynb @@ -355,6 +355,9 @@ " gmin = weights[0:nrow, 0:ncol].min()\n", " gmax = weights[0:nrow, 0:ncol].max()\n", " \n", + " if isinstance(gmin, torch.Tensor):\n", + " gmin = gmin.item()\n", + " gmax = gmax.item()\n", " return gmin, gmax\n", "\n", "def plot_param_kernels(model, weights, layout, size_ctrl, binary_mask=False, color_normalization='Model', \n", -- GitLab