learnergy/visual/tensor.py
def show_tensor(tensor):
    """Plots a tensor in grayscale mode using Matplotlib.

    Args:
        tensor (Tensor): An input tensor to be plotted.

    """

    # Creates a matplotlib figure
    plt.figure()

    # Checks if tensor has 3 channels
    if tensor.size(0) == 3:
        # If yes, permutes the tensor
        tensor = tensor.permute(1, 2, 0)

        # Plots without a color map
        plt.imshow(tensor.cpu().detach().numpy())

    # If the tensor is grayscale
    else:
        # Plots the numpy version of the tensor (grayscale)
        plt.imshow(tensor.cpu().detach().numpy(), cmap=plt.cm.get_cmap('gray'))

    # Disables all axis' ticks
    plt.xticks([])
    plt.yticks([])

    # Shows the plot
    plt.show()
Plots a tensor in grayscale mode using Matplotlib.

    Args:
        tensor (Tensor): An input tensor to be plotted.

    
Plots a tensor in grayscale mode using Matplotlib.
Plots a tensor in grayscale mode using Matplotlib .
def show_tensor(tensor):
    plt.figure()
    if tensor.size(0) == 3:
        tensor = tensor.permute(1, 2, 0)
        plt.imshow(tensor.cpu().detach().numpy())
    else:
        plt.imshow(tensor.cpu().detach().numpy(), cmap=plt.cm.get_cmap('gray'))
    plt.xticks([])
    plt.yticks([])
    plt.show()
def show_tensor ( tensor ) : plt . figure ( ) if tensor . size ( 0 ) == 3 : tensor = tensor . permute ( 1 , 2 , 0 ) plt . imshow ( tensor . cpu ( ) . detach ( ) . numpy ( ) ) else : plt . imshow ( tensor . cpu ( ) . detach ( ) . numpy ( ) , cmap = plt . cm . get_cmap ( 'gray' ) ) plt . xticks ( [ ] ) plt . yticks ( [ ] ) plt . show ( )
Plots a tensor in grayscale mode using Matplotlib.
Plots a tensor in grayscale mode using Matplotlib .
"""Plots a tensor in grayscale mode using Matplotlib.

    Args:
        tensor (Tensor): An input tensor to be plotted.

    """ # Creates a matplotlib figure # Checks if tensor has 3 channels # If yes, permutes the tensor # Plots without a color map # If the tensor is grayscale # Plots the numpy version of the tensor (grayscale) # Disables all axis' ticks # Shows the plot
tensor
An input tensor to be plotted.
An input tensor to be plotted .