如何在 CNN 期间看到处理后的图像?
我现在正在研究 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,这有点棘手,让我与您分享我的想法:
如果您只是想了解简单的神经网络内部发生的情况,请查看此链接。
如果您想可视化,请检查此存储库。您只需将笔记本的最后部分与您的模型同步,它有一个很酷的动画,您可以在 LENET MNIST 中看到
更多技术概念,包括了解类似 CNN 的模型如何做出决策的主题,例如XAI,更具体地说 grad-cam
希望这些有帮助。
Usually, this is a little bit tricky, let me share with you what is on top of my mind:
if you just want to get a sense of what's happing inside a simple neural net check out this link.
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
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.