将 Torch 中的 AAABBB 张量表格转换为嵌套的 ABABAB 张量表格

我一直在尝试解决这个问题,但仍然无法想出解决方案,也许有人可以在这里帮助我。我有以下输入表格传递给神经网络:

{
  1 :
    {
      1 : DoubleTensor - size: 32x200
      2 : DoubleTensor - size: 32x200
      3 : DoubleTensor - size: 32x200
    }
  2 :
    {
      1 : DoubleTensor - size: 32x54
      2 : DoubleTensor - size: 32x54
      3 : DoubleTensor - size: 32x54
    }
}

上述表格得到预处理后,需要转换为嵌套的 ABABAB 输入表格:

{
  1 :
    {
      1 : DoubleTensor - size: 32x200
      2 : DoubleTensor - size: 32x54
    }
  2 :
    {
      1 : DoubleTensor - size: 32x200
      2 : DoubleTensor - size: 32x54
    }
  3 :
    {
      1 : DoubleTensor - size: 32x200
      2 : DoubleTensor - size: 32x54
    }
}

我要如何使用Torch表层将 AAABBB 表格转换为网络内部的 ABABAB 嵌套表格呢?

点赞
用户1984680
用户1984680

看起来 dpnn 包含一个容器,可以完成正好这个功能。ZipTable将一个由表格组成的表格压缩成一个由表格组成的表格。

下面是一个工作示例,将 AAABBB 表格转换为 ABABAB嵌套 表格。

require 'dpnn'

aaa = torch.DoubleTensor(3,32,200)
bbb = torch.DoubleTensor(3,32,54)

model = nn.Sequential()
par = nn.ParallelTable()
par:add(nn.SplitTable(1))
par:add(nn.SplitTable(1))
model:add(par)
model:add(nn.ZipTable())
model:forward({aaa,bbb})
2017-03-02 12:12:26