这是我想出的解决方案。谢谢@mprat的帮助。在
我发现spectralcolormap最适合这种任务,而且
我还添加了您可以指定的边框。在from matplotlib import pyplot
import numpy as np
border = 2
images_amount = 300
row_amount = 10
col_amount = 30
image_height = 28
image_width = 28
all_filter_image = np.zeros((row_amount*image_height + border*row_amount,
col_amount*image_width + border*col_amount))
for filter_num in range(images_amount):
start_row = image_height*(filter_num / col_amount) +\
(filter_num / col_amount + 1)*border
end_row = start_row + image_height
start_col = image_width*(filter_num % col_amount) +\
(filter_num % col_amount + 1)*border
end_col = start_col + image_width
all_filter_image[start_row:end_row, start_col:end_col] = \
all_filters[filter_num]
print start_row, end_row, start_col, end_col
pyplot.imshow(all_filter_image)
pyplot.axis('off')
pyplot.set_cmap('spectral')
pyplot.colorbar()
pyplot.savefig('repflds1.png')
以下是一些用法示例:
不太训练有素的网络:
训练有素的网络:
正如你所看到的,边界使得区分一个过滤器(权重)和另一个过滤器变得非常容易。在