Skip to content

Instantly share code, notes, and snippets.

View LeeSinLiang's full-sized avatar
🕶️
Studying

Architect LeeSinLiang

🕶️
Studying
View GitHub Profile
@LeeSinLiang
LeeSinLiang / models.py
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)
else:
inputs = module(inputs)
return inputs