This module is similar to luatorch's Parallel Table input: N tensor network: N module output: N tensor
| 175 | |
| 176 | |
| 177 | class ParallelModule(nn.Module): |
| 178 | """ |
| 179 | This module is similar to luatorch's Parallel Table |
| 180 | input: N tensor |
| 181 | network: N module |
| 182 | output: N tensor |
| 183 | """ |
| 184 | def __init__(self, parallel_modules): |
| 185 | super(ParallelModule, self).__init__() |
| 186 | self.m = nn.ModuleList(parallel_modules) |
| 187 | |
| 188 | def forward(self, x): |
| 189 | res = [] |
| 190 | for i in range(len(x)): |
| 191 | res.append(self.m[i](x[i])) |
| 192 | |
| 193 | return res |
| 194 | |
| 195 | |
| 196 | class ClassifierModule(nn.Module): |