Skip to main content

NN Components

Module: Neural Network Module Logic

Classes

ClassDescription
ModuleGeneric neural network module.
FlattenFlatten layer implementation.
LinearLinear layer implementation.
AvgPool2d2D-Average pooling layer implementation.
DotProductSimilarityDot product similarity module.
ReLUReLU layer implementation.
Conv2dConv2D layer implementation.
ParameterParameter class.
LinearRegressionLinear regression implementation
LogisticRegressionLogistic regression implementation
ProphetProphet forecasting implementation

Model Clients

ClassDescription
ProphetClientModelClient for Prophet models
SklearnClientModelClient for Scikit-learn models
TorchClientModelClient for PyTorch models
ModelClientMetaML model client metaclass
ModelClientML model client

Class: Module

MethodDescription
forward(x: na.NadaArray) -> na.NadaArrayAbstract method for forward pass.
__call__(*args, **kwargs) -> na.NadaArrayProxy 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() -> intReturns total number of elements in the module.
load_state_from_network(name: str, party: Party, nada_type: NadaInteger) -> NoneLoads the model state from the Nillion network.

Class: Flatten

MethodDescription
__init__(start_dim: int = 1, end_dim: int = -1) -> NoneInitializes the flatten layer with start and end dimensions.
forward(x: na.NadaArray) -> na.NadaArrayForward pass. Flattens the input tensor.

Class: Linear

MethodDescription
__init__(in_features: int, out_features: int, include_bias: bool = True) -> NoneInitializes the linear layer with input features, output features, and an optional bias.
forward(x: na.NadaArray) -> na.NadaArrayForward pass. Applies a linear transformation to the input.

Class: AvgPool2d

MethodDescription
__init__(kernel_size: ShapeLike2d, stride: Optional[ShapeLike2d] = None, padding: ShapeLike2d = 0) -> NoneInitializes the 2D average pooling layer.
forward(x: na.NadaArray) -> na.NadaArrayForward pass. Applies average pooling to the input.

Class: DotProductSimilarity

MethodDescription
forward(x_1: na.NadaArray, x_2: na.NadaArray) -> na.NadaArrayForward pass. Computes the dot product similarity between two input arrays.

Class: ReLU

MethodDescription
forward(x: na.NadaArray) -> na.NadaArrayForward 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

MethodDescription
__init__(in_channels: int, out_channels: int, kernel_size: ShapeLike2d, padding: ShapeLike2d = 0, stride: ShapeLike2d = 1, include_bias: bool = True) -> NoneInitializes the 2D convolutional layer.
forward(x: na.NadaArray) -> na.NadaArrayForward pass. Applies 2D convolution to the input.

Class: Parameter

MethodDescription
__init__(shape: ShapeLike = 1) -> NoneInitializes the parameter with a given shape.
numel() -> intReturns the number of elements in the parameter.
load_state(state: na.NadaArray) -> NoneLoads a provided NadaArray as the new parameter state.

Linear Models

Class NameDescriptionMethods
LinearRegressionLinear regression implementation__init__(in_features: int, include_bias: bool = True) -> None
forward(x: na.NadaArray) -> na.NadaArray
LogisticRegressionLogistic regression implementation__init__(in_features: int, out_features: int, include_bias: bool = True) -> None
forward(x: na.NadaArray) -> na.NadaArray

Time Series Models

Class NameDescriptionMethods
ProphetProphet 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 NameDescriptionMethods
ProphetClientModelClient for Prophet models__init__(model: prophet.forecaster.Prophet) -> None
SklearnClientModelClient for Scikit-learn models__init__(model: sklearn.base.BaseEstimator) -> None
TorchClientModelClient for PyTorch models__init__(model: nn.Module) -> None
ModelClientMetaML model client metaclass__call__(cls, *args, **kwargs) -> object
ModelClientML model clientexport_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.