给出以下模型,是否可以从每个卷积滤波器中获取图像?我似乎找不到解决方法。
tf.enable_eager_execution()
l = tf.keras.layers
max_pool = l.MaxPooling2D((2, 2), (2, 2), padding='same', data_format=data_format)
kmodel = tf.keras.Sequential(
[
l.Reshape(target_shape=input_shape, input_shape=(IMAGE_SIZE * IMAGE_SIZE * colors,)),
l.Conv2D(32, (5,5), padding='same', data_format=data_format, activation=tf.nn.relu),
max_pool,
l.Conv2D(64, (5,5), padding='same', data_format=data_format, activation=tf.nn.relu),
max_pool,
l.Conv2D(128, (5,5), padding='same', data_format=data_format, activation=tf.nn.relu),
max_pool,
l.Conv2D(256, (5,5), padding='same', data_format=data_format, activation=tf.nn.relu),
max_pool,
l.Flatten(),
l.Dense(1024, activation=tf.nn.relu),
l.Dropout(0.4),
l.Dense(num_classes) #num_classes
]
)
# how to get tf.contrib.image for each of the 4 filters?
靠近但没有雪茄:
https://stackoverflow.com/a/35858950
https://github.com/InFoCusp/tf_cnnvis
谢谢!
说明更新:也使用tf.GradientTape API