Plots a two-dimensional image and its corresponding spike-train representation. :param image: A 2D array of floats depicting an input image. :param inpt: A 2D array of floats depicting an image's spike-train encoding. :param label: Class label of the input data. :param axes: Us
(
image: torch.Tensor,
inpt: torch.Tensor,
label: Optional[int] = None,
axes: List[Axes] = None,
ims: List[AxesImage] = None,
figsize: Tuple[int, int] = (8, 4),
)
| 19 | |
| 20 | |
| 21 | def plot_input( |
| 22 | image: torch.Tensor, |
| 23 | inpt: torch.Tensor, |
| 24 | label: Optional[int] = None, |
| 25 | axes: List[Axes] = None, |
| 26 | ims: List[AxesImage] = None, |
| 27 | figsize: Tuple[int, int] = (8, 4), |
| 28 | ) -> Tuple[List[Axes], List[AxesImage]]: |
| 29 | # language=rst |
| 30 | """ |
| 31 | Plots a two-dimensional image and its corresponding spike-train representation. |
| 32 | |
| 33 | :param image: A 2D array of floats depicting an input image. |
| 34 | :param inpt: A 2D array of floats depicting an image's spike-train encoding. |
| 35 | :param label: Class label of the input data. |
| 36 | :param axes: Used for re-drawing the input plots. |
| 37 | :param ims: Used for re-drawing the input plots. |
| 38 | :param figsize: Horizontal, vertical figure size in inches. |
| 39 | :return: Tuple of ``(axes, ims)`` used for re-drawing the input plots. |
| 40 | """ |
| 41 | local_image = image.detach().clone().cpu().numpy() |
| 42 | local_inpy = inpt.detach().clone().cpu().numpy() |
| 43 | |
| 44 | if axes is None: |
| 45 | fig, axes = plt.subplots(1, 2, figsize=figsize) |
| 46 | ims = ( |
| 47 | axes[0].imshow(local_image, cmap="binary", aspect="auto"), |
| 48 | axes[1].imshow(local_inpy, cmap="binary", aspect="auto"), |
| 49 | ) |
| 50 | |
| 51 | if label is None: |
| 52 | axes[0].set_title("Current image") |
| 53 | else: |
| 54 | axes[0].set_title("Current image (label = %d)" % label) |
| 55 | |
| 56 | axes[1].set_title("Reconstruction") |
| 57 | |
| 58 | for ax in axes: |
| 59 | ax.set_xticks(()) |
| 60 | ax.set_yticks(()) |
| 61 | |
| 62 | fig.tight_layout() |
| 63 | else: |
| 64 | if label is not None: |
| 65 | axes[0].set_title("Current image (label = %d)" % label) |
| 66 | |
| 67 | ims[0].set_data(local_image) |
| 68 | ims[1].set_data(local_inpy) |
| 69 | |
| 70 | return axes, ims |
| 71 | |
| 72 | |
| 73 | def plot_spikes( |
no test coverage detected