0

この NN のパラメータを回復しようとしています:

    nn.Sequential {
      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> output]
      (1): nn.Linear(4 -> 200)
      (2): nn.Tanh
      (3): nn.Linear(200 -> 200)
      (4): nn.Tanh
      (5): nn.Linear(200 -> 3)
      (6): nn.LogSoftMax         
    }

このコードを使用して:

print(mlp:get(1).weight)
print(mlp:get(1).bias)

print(mlp:get(3).weight)
print(mlp:get(3).bias)

print(mlp:get(5).weight)
print(mlp:get(5).bias)

次のコマンド ラインを使用して出力 .lua ファイルをテキスト ファイルに保存する場合:

>>th  'MyScript.lua' > NNParameters.txt

すべての重みマトリックスをそれぞれ 6 列のセグメントにラップします (列 1 から 6 ... 列 193 から 198 ... 列 199 から 200)。

テキストが折り返されて重み行列が 1 つのブロックだけに表示されるのを防ぐ方法はありますか?

ありがとうございました。

4

2 に答える 2

1
printT = function(t)
   t = t:view(-1)
   for i=1,t:nElement() do
      io.write(t[i] .. ',')
   end
end

printT(mlp:get(1).weight)
printT(mlp:get(1).bias)

printT(mlp:get(3).weight)
printT(mlp:get(3).bias)

printT(mlp:get(5).weight)
printT(mlp:get(5).bias)
于 2015-05-04T17:42:30.233 に答える
0

実際にやりたいことは、パラメーターを保存して後で読み込めるようにすることだと思いますか? その場合、これを見てください:

https://github.com/torch/torch7/blob/master/doc/serialization.md

于 2015-05-04T08:02:22.897 に答える