[Python] Visualize Filters of CNN using Tensor Flow

Discussão em 'Python' iniciado por Stack, Junho 25, 2025.

  1. Stack

    Stack Membro Participativo

    Im working on Visualizing Filters of a CNN using TensorFlow - Guided Project in coursera. I encountered the error when trying to call the plot_image function. I defined the size of the image error screenshot as (96,96,3) but it takes as (1,96,96,3)

    def create_image():

    im = tf.random.uniform((96,96,3),minval=0.5,maxval=0.5)

    return im

    def plot_image(image,title ='random'):

    image =image - tf.math.reduce_min(image),

    image =image / tf.math.reduce_max(image)

    plt.imshow(image)

    plt.xticks([])

    plt.yticks([])

    plt.title(title)

    plt.imshow(image)

    plt.show()

    image = create_image()
    plot_image(image)


    I tried using

    image_data_channels_first = np.random.rand(3, 96, 96)
    image_data_channels_last = np.moveaxis(image_data_channels_first, 0, -1)


    Squeeze method also i tried, it didnt work. Im encountering same error when calling the function.

    Continue reading...

Compartilhe esta Página