c++ - 如何在烤宽面条中打印隐藏层的输出

标签 c++ neural-network theano lasagne

我正在尝试使用 lasgne 来训练一个简单的神经网络,并使用我自己的 C++ 代码进行推理。我使用 lasgne 生成的权重,但无法获得好的结果。有没有办法打印隐藏层的输出和/或计算本身?我想看看它在幕后工作的是谁,这样我就可以在 C++ 中以相同的方式实现它。

最佳答案

我可以在 Python 中使用 Lasagne + Theano 提供帮助,根据你的问题我不确定你是否完全使用 C++ 工作,或者你只需​​要在你的 C++ 代码中使用 Python + Lasagne 的结果。

假设您有一个像这样的简单网络:

l_in = lasagne.layers.InputLayer(...)
l_in_drop = lasagne.layers.DropoutLayer(l_in, ...)
l_hid1 = lasagne.layers.DenseLayer(l_in_drop, ...)
l_out = lasagne.layers.DenseLayer(l_hid1, ...)

可以通过调用特定层的get_output方法来获取每一层的输出:

lasagne.layers.get_output(l_in, deterministic=False) # this will just give you the input tensor
lasagne.layers.get_output(l_in_drop, deterministic=True)
lasagne.layers.get_output(l_hid1, deterministic=True)
lasagne.layers.get_output(l_out, deterministic=True)

当你处理 dropout 并且你不在训练阶段时,重要的是要记住调用 get_output 方法并将 deterministic 参数设置为 True,以避免非确定性行为。这适用于一个或多个 dropout 层之前的所有层。

我希望这能回答您的问题。

关于c++ - 如何在烤宽面条中打印隐藏层的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45252752/

相关文章:

c++ - CredMartialCredentials 用户名提示(智能卡)

c++ - 找不到 -lSDL 的库

tensorflow - 创建VGG16时来自Tensorflow的警告

R:nrow[w] * ncol[w] 中的错误:二元运算符的非数字参数,同时使用神经网络包

c# - PInvoke 不平衡堆栈

java - 需要帮助选择数据挖掘/神经网络 API

neural-network - tensorflow 在 GPU 内存上存储训练数据

python - Python 中的函数声明

windows - 无法在上下文 None 上使用 cuDNN, fatal error : cudnn. h:没有这样的文件或目录

c++ - 方程式相等性测试(在C++或Unix工具中)(代数函数同构)