← HomOps Reference
HomReLU
Apply an encrypted ReLU approximation, element by element.
RePolynomials
RunsServer
Changes shapeNo
Changes scaleYes: through HomSign and multiplication
Levels spentSeveral
RotatesNo
KeysSquare key
What it does
HomReLU is an encrypted composite, not a cleartext max(0, x) leaf. It computes (approx_sign(x) + 1/2) * x on the domain [-1, 1], using HomSign (scale=0.5) for the sign approximation.The approximation domain is fixed:
left must be -1.0 and right must be 1.0. Because Sign uses polynomial stages and the final operation is a ciphertext multiply, this consumes levels and requires the square key.Signature
HomReLU( x_accuracy=10, y_accuracy=10, left=-1.0, # must be -1.0 right=1.0, # must be 1.0 tol=1e-8, rows_budget=None, )
No
set_data. The constructor configures the HomSign approximation used by this composite.Parameters
ParameterTypeDefaultDescription
x_accuracyint10Horizontal accuracy used to calibrate the Sign approximation.y_accuracyfloat10Vertical accuracy for the Sign/minimax approximation.leftfloat-1.0Required domain left bound; must be -1.0.rightfloat1.0Required domain right bound; must be 1.0.tolfloat1e-8Polynomial tolerance forwarded to the Sign stages.rows_budgetSequence[int] | NoneNoneAbsolute rows available to Sign and polynomial-stage mod-switches.Requirements
- Input in [-1, 1]. The composite enforces
left=-1.0andright=1.0; normalize inputs before it. - Square key and level headroom. HomSign and the final encrypted multiply consume the same resources as their constituent operations.
Shape effect - no
The output shape equals the input shape.
Scale effect - yes
Scale changes through the HomSign polynomial stages and the final ciphertext multiply. Inspect the compiled pipeline to plan the next operation.
Level budget
Several. HomSign consumes levels through polynomial evaluation, and the final multiply follows HomMul behavior.
Keys
Square key. Needed by HomSign and the final ciphertext multiplication.
Example
An encrypted activation in the
hom section, after inputs have been normalized to [-1, 1]:pipeline.pyPYTHON
from lattica_build.operators import HomLinear, HomReLU from lattica_build.base_classes.hom_pipeline import HomomorphicPipeline from lattica_build.operators.composite.sequential import SequentialHomOp pipeline = HomomorphicPipeline( hom=SequentialHomOp( HomLinear((64, 128), bias=True), HomReLU(x_accuracy=10, y_accuracy=10), # encrypted via HomSign HomLinear((10, 64), bias=True), ), input_shape=(128,), )
See also
- HomSign - the encrypted approximation used by this composite
- HomSquare · HomPolyEval - other encrypted nonlinearities