回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>最后,我从一个文件中训练了一个网络:)现在我想打印节点和权重,特别是权重,因为我想用pybrain训练网络,然后在其他地方实现一个使用它的NN。</p>
<p>我需要一种方法来打印层、节点和节点之间的权重,这样我就可以轻松地复制它。到目前为止,我可以使用n['in']访问层,例如,我可以执行以下操作:</p>
<blockquote>
<blockquote>
<blockquote>
<p>dir(n['in'])
['<strong>class</strong>', '<strong>delattr</strong>', '<strong>dict</strong>', '<strong>doc</strong>', '<strong>format</strong>', '<strong>getattribute</strong>', '<strong>hash</strong>', '<strong>init</strong>', '<strong>module</strong>', '<strong>new</strong>', '<strong>reduce</strong>', '<strong>reduce_ex</strong>', '<strong>repr</strong>', '<strong>setattr</strong>', '<strong>sizeof</strong>', '<strong>str</strong>', '<strong>subclasshook</strong>', '<strong>weakref</strong>', '_backwardImplementation', '_forwardImplementation', '_generateName', '_getName', '_growBuffers', '_name', '_nameIds', '_resetBuffers', '_setName', 'activate', 'activateOn<a href="https://www.cnpython.com/pypi/dataset" class="inner-link">dataset</a>', 'argdict', 'backActivate', 'backward', 'bufferlist', 'dim', 'forward', 'getName', 'indim', 'inputbuffer', 'inputerror', 'name', 'offset', 'outdim', 'outputbuffer', 'outputerror', 'paramdim', 'reset', 'sequential', 'setArgs', 'setName', 'shift', 'whichNeuron']</p>
</blockquote>
</blockquote>
</blockquote>
<p>但我不知道我怎么能拿到这里的重量。还有params属性,例如my network is 241 with bias,它显示:</p>
<blockquote>
<blockquote>
<blockquote>
<p>n.params
array([-0.8167133 , 1.00077451, -0.7591257 , -1.1150532 , -1.58789386,
0.11625991, 0.98547457, -0.99397871, -1.8324281 , -2.42200963,
1.90617387, 1.93741167, -2.88433965, 0.27449852, -1.52606976,
2.39446258, 3.01359547])</p>
</blockquote>
</blockquote>
</blockquote>
<p>很难说是什么,至少用重量连接哪些节点。这就是我所需要的。</p>