Added various activation function nodes and chained model node.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
from typing import Any, Dict, Tuple, Callable
|
||||
import torch
|
||||
|
||||
|
||||
class PtApplyFunction:
|
||||
"""
|
||||
Applies a function to the input tensor.
|
||||
|
||||
### Fields:
|
||||
- tens: Tensor to which the function be applied.
|
||||
- closure: Differentiable function to apply to the tensor.
|
||||
|
||||
category: PyTorch wrapper - Training
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the expected input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required and optional input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens": ("TENSOR", {}),
|
||||
"closure": ("PTCALLABLE", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: Tuple[str, ...] = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Training"
|
||||
|
||||
def f(self,
|
||||
tens: torch.Tensor,
|
||||
closure: Callable) -> Tuple[torch.Tensor]:
|
||||
"""
|
||||
Applies a function to the input tensor.
|
||||
|
||||
Args:
|
||||
tens (torch.Tensor): Tensor to which the function be applied.
|
||||
closure (Callable): Differentiable function to apply to the tensor.
|
||||
|
||||
Returns:
|
||||
Tuple[nn.Module]: A tuple containing the instantiated model.
|
||||
"""
|
||||
return (closure(tens),)
|
||||
Reference in New Issue
Block a user