绘制隐藏权重

Plotting Hidden Weights

我对神经网络感兴趣已有一段时间了,并且刚刚开始学习深度学习教程。我有一个我希望是一个相对直接的问题,我希望有人可以回答。

在多层感知教程中,我有兴趣查看不同层的网络状态(类似于本文中看到的内容:http://www.iro.umontreal.ca/~lisa/publications2/index.php/publications/show/247)。例如,我可以使用以下方式写出隐藏层的权重:

    W_open = open('mlp_w_pickle.pkl','w')
cPickle.dump(classifier.hiddenLayer.W.get_value(borrow=True), W_open, -1)

当我使用 utils.py tile plotting 绘制它时,我得到以下漂亮的图 [编辑:漂亮的图 rmoved 因为我没有足够的代表]。

如果我想在 logRegressionLayer 上绘制权重,这样

cPickle.dump(classifier.logRegressionLayer.W.get_value(borrow=True), W_open, -1)

我实际上需要做什么?以上似乎不起作用 - 它 returns 一个 2darray 的形状 (500,10)。我知道 500 与隐藏单元的数量有关。杂页上的段落:

Plotting the weights is a bit more tricky. We have n_hidden hidden units, each of them corresponding to a column of the weight matrix. A column has the same shape as the visible, where the weight corresponding to the connection with visible unit j is at position j. Therefore, if we reshape every such column, using numpy.reshape, we get a filter image that tells us how this hidden unit is influenced by the input image.

让我有点困惑。我不确定我将如何把它串在一起。

感谢大家 - 如果问题令人困惑,请见谅!

您可以像第一层中的权重一样绘制它们,但它们不一定有多大意义。

考虑神经网络第一层中的权重。如果输入的大小为 784(例如 MNIST 图像)并且第一层中有 2000 个隐藏单元,那么第一层权重是一个大小为 784x2000 的矩阵(或者可能是转置,具体取决于它的实现方式)。这些权重可以绘制为 784 个大小为 2000 的补丁,或者更常见的是,2000 个大小为 784 的补丁。在后一种情况下,每个补丁可以绘制为 28x28 图像,它直接与原始输入相关联,因此是可解释的。

对于更高级别的回归层,您可以绘制 10 个图块,每个图块大小为 500(例如,大小为 22x23 的图块加上一些填充以使其成为矩形),或者 500 个图块大小为 10。两者都可以说明一些模式正在被发现,但可能很难将这些模式与原始输入联系起来。