gpt4 book ai didi

python - Lasagne/nolearn autoencoder - 如何获得隐藏层输出?

转载 作者:太空狗 更新时间:2023-10-30 00:13:48 24 4
gpt4 key购买 nike

我使用 lasagne/nolearn 训练了一个自动编码器。假设网络层是 [500, 100, 100, 500]。我已经像这样训练了神经网络:

net.fit(X, X)

我想做如下的事情:

net.predict(X, layer=2)

所以我会得到我的数据的抑制表示。因此,如果我的初始数据的形状为 [10000, 500],则结果数据将为 [10000, 100]。

我进行了搜索,但找不到该怎么做。千层面/nolearn 有可能吗?

最佳答案

看起来答案在文档中: http://lasagne.readthedocs.org/en/latest/user/layers.html#propagating-data-through-layers

以下是相关部分:

To compute the output of a network, you should instead call lasagne.layers.get_output() on it. This will traverse the network graph.

You can call this function with the layer you want to compute the output expression for:

>>> y = lasagne.layers.get_output(l_out)

In that case, a Theano expression will be returned that represents the output in function of the input variables associated with the lasagne.layers.InputLayer instance (or instances) in the network

...

You can also specify a Theano expression to use as input as a second argument to lasagne.layers.get_output():

>>> x = T.matrix('x')
>>> y = lasagne.layers.get_output(l_out, x)
>>> f = theano.function([x], y)

假设 netnolearn.lasagne.NeuralNet 类型,看起来您可以使用 net.get_all_layers()。我没有在文档中看到它,但它是 here在第 592 行。

关于python - Lasagne/nolearn autoencoder - 如何获得隐藏层输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33832740/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com