如何在 CNN 期间看到处理后的图像?

发布于 2025-01-12 04:45:49 字数 854 浏览 0 评论 0原文

我现在正在研究 python 深度学习代码。我想知道我设计的网络内部发生了什么。下面是我正在处理的示例代码。

我的问题是,是否可以在网络中看到处理后的图像?例如,我想看看我的输入图像在“p1”和“p2”之后如何变化。是否可以?如果可以的话,怎样才能看到呢?

import tensorflow as tf
IMG_WIDTH = 256
IMG_HEIGHT = 256
IMG_CHANNELS = 3
#define input
inputs = tf.keras.layers.Input(shape=(IMG_WIDTH, IMG_HEIGHT, IMG_CHANNELS))
# s = tf.keras.layers.Lambda(lambda x: x/255)(inputs)

#define Contraction path
c1_1 = tf.keras.layers.Conv2D(64,(3,3),activation='relu', padding='same')(inputs)
c1_2 = tf.keras.layers.Conv2D(64,(3,3),activation='relu', padding='same')(c1_1)
p1 = tf.keras.layers.MaxPooling2D((2,2), strides = 2)(c1_2)

c2_1 = tf.keras.layers.Conv2D(128,(3,3),activation='relu', padding='same')(p1)
c2_2 = tf.keras.layers.Conv2D(128,(3,3),activation='relu', padding='same')(c2_1)
p2 = tf.keras.layers.MaxPooling2D((2,2), strides = 2)(c2_2)

Im working on python deep learning code right now. And I want to know what is going on inside the network I designed. Down here is my sample code Im working on.

My question is, is it possible to see the processed image inside Network? For example, I want to see how my input image changed after "p1" and "p2". Is it possible? If it is possible, how can I see it?

import tensorflow as tf
IMG_WIDTH = 256
IMG_HEIGHT = 256
IMG_CHANNELS = 3
#define input
inputs = tf.keras.layers.Input(shape=(IMG_WIDTH, IMG_HEIGHT, IMG_CHANNELS))
# s = tf.keras.layers.Lambda(lambda x: x/255)(inputs)

#define Contraction path
c1_1 = tf.keras.layers.Conv2D(64,(3,3),activation='relu', padding='same')(inputs)
c1_2 = tf.keras.layers.Conv2D(64,(3,3),activation='relu', padding='same')(c1_1)
p1 = tf.keras.layers.MaxPooling2D((2,2), strides = 2)(c1_2)

c2_1 = tf.keras.layers.Conv2D(128,(3,3),activation='relu', padding='same')(p1)
c2_2 = tf.keras.layers.Conv2D(128,(3,3),activation='relu', padding='same')(c2_1)
p2 = tf.keras.layers.MaxPooling2D((2,2), strides = 2)(c2_2)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

來不及說愛妳 2025-01-19 04:45:49

通常,这有点棘手,让我与您分享我的想法:

  1. 如果您只是想了解简单的神经网络内部发生的情况,请查看此链接

  2. 如果您想可视化,请检查此存储库。您只需将笔记本的最后部分与您的模型同步,它有一个很酷的动画,您可以在 LENET MNIST 中看到

  3. 更多技术概念,包括了解类似 CNN 的模型如何做出决策的主题,例如XAI,更具体地说 grad-cam

希望这些有帮助。

Usually, this is a little bit tricky, let me share with you what is on top of my mind:

  1. if you just want to get a sense of what's happing inside a simple neural net check out this link.

  2. If you want to visualize check this repo. you just need to sync the last sections of the notebook with your model, it has a cool animation which you can see for LENET MNIST

  3. More technical concepts getting a sense of how a CNN like model make a decision is covered with topics like XAI, and more specifically grad-cam

Hope these are helpful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文