NN Components
Module: Neural Network Module Logic
Classes
Class | Description |
---|---|
Module | Generic neural network module. |
Flatten | Flatten layer implementation. |
Linear | Linear layer implementation. |
AvgPool2d | 2D-Average pooling layer implementation. |
DotProductSimilarity | Dot product similarity module. |
ReLU | ReLU layer implementation. |
Conv2d | Conv2D layer implementation. |
Parameter | Parameter class. |
LinearRegression | Linear regression implementation |
LogisticRegression | Logistic regression implementation |
Prophet | Prophet forecasting implementation |
Model Clients
Class | Description |
---|---|
ProphetClient | ModelClient for Prophet models |
SklearnClient | ModelClient for Scikit-learn models |
TorchClient | ModelClient for PyTorch models |
ModelClientMeta | ML model client metaclass |
ModelClient | ML model client |
Class: Module
Method | Description |
---|---|
forward(x: na.NadaArray) -> na.NadaArray | Abstract method for forward pass. |
__call__(*args, **kwargs) -> na.NadaArray | Proxy for forward pass. |
__named_parameters(prefix: str) -> Iterator[Tuple[str, Parameter]] | Recursively generates all parameters in the module. |
named_parameters() -> Iterator[Tuple[str, Parameter]] | Generates all parameters in the module. |
__numel() -> Iterator[int] | Recursively generates number of elements in each parameter. |
numel() -> int | Returns total number of elements in the module. |
load_state_from_network(name: str, party: Party, nada_type: NadaInteger) -> None | Loads the model state from the Nillion network. |
Class: Flatten
Method | Description |
---|---|
__init__(start_dim: int = 1, end_dim: int = -1) -> None | Initializes the flatten layer with start and end dimensions. |
forward(x: na.NadaArray) -> na.NadaArray | Forward pass. Flattens the input tensor. |
Class: Linear
Method | Description |
---|---|
__init__(in_features: int, out_features: int, include_bias: bool = True) -> None | Initializes the linear layer with input features, output features, and an optional bias. |
forward(x: na.NadaArray) -> na.NadaArray | Forward pass. Applies a linear transformation to the input. |
Class: AvgPool2d
Method | Description |
---|---|
__init__(kernel_size: ShapeLike2d, stride: Optional[ShapeLike2d] = None, padding: ShapeLike2d = 0) -> None | Initializes the 2D average pooling layer. |
forward(x: na.NadaArray) -> na.NadaArray | Forward pass. Applies average pooling to the input. |
Class: DotProductSimilarity
Method | Description |
---|---|
forward(x_1: na.NadaArray, x_2: na.NadaArray) -> na.NadaArray | Forward pass. Computes the dot product similarity between two input arrays. |
Class: ReLU
Method | Description |
---|---|
forward(x: na.NadaArray) -> na.NadaArray | Forward pass. Applies the ReLU activation function to the input. |
static _rational_relu(value: Union[na.Rational, na.SecretRational]) -> Union[na.Rational, na.SecretRational] | Element-wise ReLU logic for rational values. |
static _relu(value: NadaType) -> Union[PublicInteger, SecretInteger] | Element-wise ReLU logic for NadaType values. |
Class: Conv2d
Method | Description |
---|---|
__init__(in_channels: int, out_channels: int, kernel_size: ShapeLike2d, padding: ShapeLike2d = 0, stride: ShapeLike2d = 1, include_bias: bool = True) -> None | Initializes the 2D convolutional layer. |
forward(x: na.NadaArray) -> na.NadaArray | Forward pass. Applies 2D convolution to the input. |
Class: Parameter
Method | Description |
---|---|
__init__(shape: ShapeLike = 1) -> None | Initializes the parameter with a given shape. |
numel() -> int | Returns the number of elements in the parameter. |
load_state(state: na.NadaArray) -> None | Loads a provided NadaArray as the new parameter state. |
Linear Models
Class Name | Description | Methods |
---|---|---|
LinearRegression | Linear regression implementation | __init__(in_features: int, include_bias: bool = True) -> None forward(x: na.NadaArray) -> na.NadaArray |
LogisticRegression | Logistic regression implementation | __init__(in_features: int, out_features: int, include_bias: bool = True) -> None forward(x: na.NadaArray) -> na.NadaArray |
Time Series Models
Class Name | Description | Methods |
---|---|---|
Prophet | Prophet forecasting implementation | __init__(n_changepoints: int, growth: str = "linear", yearly_seasonality: bool = True, weekly_seasonality: bool = True, daily_seasonality: bool = False, seasonality_mode: str = "additive") -> None predict(dates: np.ndarray, floor: na.NadaArray, t: na.NadaArray) -> na.NadaArray predict_trend(floor: na.NadaArray, t: na.NadaArray) -> na.NadaArray predict_seasonal_comps(dates: np.ndarray) -> Tuple[na.NadaArray, na.NadaArray] make_seasonality_features(dates: np.ndarray, seasonalities: Dict[str, Any]) -> Dict[str, na.NadaArray] ensure_numeric_dates(dates: np.ndarray) -> np.ndarray __call__(dates: np.ndarray, floor: na.NadaArray, t: na.NadaArray) -> na.NadaArray forward(dates: np.ndarray, floor: na.NadaArray, t: na.NadaArray) -> na.NadaArray |
Model Clients
Class Name | Description | Methods |
---|---|---|
ProphetClient | ModelClient for Prophet models | __init__(model: prophet.forecaster.Prophet) -> None |
SklearnClient | ModelClient for Scikit-learn models | __init__(model: sklearn.base.BaseEstimator) -> None |
TorchClient | ModelClient for PyTorch models | __init__(model: nn.Module) -> None |
ModelClientMeta | ML model client metaclass | __call__(cls, *args, **kwargs) -> object |
ModelClient | ML model client | export_state_as_secrets(name: str, nada_type: NillionType) -> Dict[str, NillionType] __ensure_numpy(array_like: Any) -> np.ndarray |
For more examples, please visit our Github Repository Examples.