テンソルを保存すると、トーチはデータだけでなく、表示されているように、後でデシリアライズするためのその他の有用な情報を保存します。
csvシリアライゼーションが必要な場合は、自分で実装するのがよいでしょう。
幸いにも、これは非常に簡単です。ここで
は簡単な例です:
require 'torch'
matrix = torch.Tensor(5,3) -- a 5x3 matrix
matrix:random(1,10) -- matrix initialized with random numbers in [1,10]
print(matrix) -- let's see the matrix content
subtensor = matrix[{{1,3}, {2,3}}] -- let's create a view on the row 1 to 3, for which we take columns 2 to 3 (the view is a 3x2 matrix, note that values are bound to the original tensor)
local out = assert(io.open("./dump.csv", "w")) -- open a file for serialization
splitter = ","
for i=1,subtensor:size(1) do
for j=1,subtensor:size(2) do
out:write(subtensor[i][j])
if j == subtensor:size(2) then
out:write("\n")
else
out:write(splitter)
end
end
end
out:close()
行列のための私のコンピュータ上の出力は次のとおりです。
10 10 6
4 8 3
3 8 5
5 5 5
1 6 8
[torch.DoubleTensor of size 5x3]
とファイルがコンテンツをダンプ:
10,6
8,3
8,5
HTH