【问题标题】:torch: what is the structure for tensors of different sizes?火炬:不同大小的张量的结构是什么?
【发布时间】:2016-10-30 17:52:12
【问题描述】:

桌子?但是在表中插入大张量效率不高,甚至不可能,因为在我的情况下是内存。这工作得很好,但很丑:

local s_ = 0
s_ = s_ + 1; local X_py_1 = fromfile(('%s/x_py_%.2f.bin'):format(data_dir, scales[s_]))
s_ = s_ + 1; local X_py_2 = fromfile(('%s/x_py_%.2f.bin'):format(data_dir, scales[s_]))
s_ = s_ + 1; local X_py_3 = fromfile(('%s/x_py_%.2f.bin'):format(data_dir, scales[s_]))
s_ = s_ + 1; local X_py_4 = fromfile(('%s/x_py_%.2f.bin'):format(data_dir, scales[s_]))
s_ = s_ + 1; local X_py_5 = fromfile(('%s/x_py_%.2f.bin'):format(data_dir, scales[s_]))
s_ = s_ + 1; local X_py_6 = fromfile(('%s/x_py_%.2f.bin'):format(data_dir, scales[s_]))
X_py = {X_py_1, X_py_2, X_py_3, X_py_4, X_py_5, X_py_6}

【问题讨论】:

  • 我想您忘记添加句子的一部分,除非您想以“table ?”开头:p
  • 我正在回答我自己的问题,但是好的,完整的句子是:是桌子吗?

标签: lua lua-table torch


【解决方案1】:

显示我的代码..请帮助你

X_py = {X_py_1, X_py_2, X_py_3, X_py_4, X_py_5, X_py_6}
for i, v in ipairs(X_py) do
    v = fromfile(('%s/x_py_%.2f.bin'):format(data_dir, scales[i-1]))
end

只用table,你想要吗?

【讨论】:

  • 不,这不起作用。之后,X_py 表为空。
【解决方案2】:

好的,这很简单:

X_py = {}
for s, scale in ipairs(scales) do
  X_py[s] = fromfile(('%s/x_py_%.2f.bin'):format(data_dir, scale))
end

【讨论】:

    猜你喜欢
    • 2021-06-18
    • 2022-11-18
    • 2016-10-06
    • 2017-02-23
    • 2020-09-08
    • 2020-09-28
    • 2019-01-19
    • 2022-07-20
    • 1970-01-01
    相关资源
    最近更新 更多