Closed kumatheworld closed 1 year ago
ChatGPT suggested I do the following, but I don't think I need to do so at the moment.
class Functional(nn.Module):
def __init__(self, func: Callable) -> None:
super().__init__()
self._forward_func = func
def forward(self, x: torch.Tensor) -> torch.Tensor:
return self._forward_func(x)
# Rest of the class implementation...
This is related to #5. Is it a good idea to do
self.forward = func
rather than overridingforward()
? So far I don't find any inconvenience but this might be bad practice in Python.