venumML.approx_functions
def
softmax_approximation(ctx, x, D):
Approximates the softmax function for encrypted data using a Taylor series expansion.
Parameters
- ctx (EncryptionContext): The encryption context used to encrypt constants in the approximation.
- x (encrypted array-like or encrypted float): The encrypted input data.
- D (encrypted float): Encrypted normalisation factor for the softmax function, usually the sum of exponentiated terms.
Returns
- encrypted array-like or encrypted float: The softmax approximation values for each input in x, encrypted.
def
tanh_approximation(ctx, x):
Approximates the hyperbolic tangent (tanh) function for encrypted data using Taylor series.
Parameters
- ctx (EncryptionContext): The encryption context used to encrypt constants in the approximation.
- x (encrypted float): The encrypted input value for the tanh function.
Returns
- encrypted float: The approximate tanh value of the input, encrypted.
def
sigmoid_approximation(ctx, x):
Approximates the sigmoid function for encrypted data using a Taylor series expansion.
Parameters
- ctx (EncryptionContext): The encryption context used to encrypt constants in the approximation.
- x (encrypted array-like or encrypted float): The encrypted input data.
Returns
- encrypted array-like or encrypted float: The sigmoid approximation values for each input in x, encrypted.