Files
pytorch-ts/pts/modules/lambda.py
T
Dr. Kashif Rasul 6e5c356320 initial modules
2019-10-28 11:59:13 +01:00

12 lines
337 B
Python

import torch
import torch.nn as nn
class Lambda(nn.Module):
def __init(self, function):
super().__init__()
func_dict = {sym: getattr(sym, function), Tensor: getattr(torch.Tensor, function)}
self._func = lambda *args: func_dict(*args)
def forward(self, x, *args):
return self._func(x, *args)