Skip to content

Instantly share code, notes, and snippets.

View LeeSinLiang's full-sized avatar

Architect LeeSinLiang

View GitHub Profile
LeeSinLiang /
Last active May 24, 2023 13:49
Enables nn.Sequential to accept multiple inputs, enhancing the flexibility of sequential neural network models.
import torch.nn as nn
class MultiInputSequential(nn.Sequential):
def forward(self, *inputs):
for module in self._modules.values():
if type(inputs) == tuple:
inputs = module(*inputs)
inputs = module(inputs)
return inputs