mirror of
https://github.com/wassname/pytorch-ts.git
synced 2026-07-10 20:01:39 +08:00
12 lines
337 B
Python
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)
|