This module is similar to luatorch's Parallel Table input: N tensor network: N module output: N tensor
| 202 | |
| 203 | |
| 204 | class ParallelModule(nn.Module): |
| 205 | """ |
| 206 | This module is similar to luatorch's Parallel Table |
| 207 | input: N tensor |
| 208 | network: N module |
| 209 | output: N tensor |
| 210 | """ |
| 211 | def __init__(self, parallel_modules): |
| 212 | super(ParallelModule, self).__init__() |
| 213 | self.m = nn.ModuleList(parallel_modules) |
| 214 | |
| 215 | def forward(self, x): |
| 216 | res = [] |
| 217 | for i in range(len(x)): |
| 218 | res.append(self.m[i](x[i])) |
| 219 | |
| 220 | return res |
| 221 | |
| 222 | |
| 223 | class ClassifierModule(nn.Module): |