Skip to content

Instantly share code, notes, and snippets.

View youben11's full-sized avatar
🏠
Working from home

Ayoub Benaissa youben11

🏠
Working from home
View GitHub Profile
ctx = h.create_context()
keys = ctx.keygen()
print(f"Simulation result: {h.simulate(x)}")
print(f"Plain NumPy result: {func(x)}")
x = np.random.uniform(-1, 1, 5)
h = hnp.compile_fhe(
func,
{
'x': hnp.encrypted_ndarray(bounds=(-1, 1), shape=(5,)),
}
)
weights = np.array([0.1, 0.2, 0.3, 0.4, 0.5])
bias = np.array([0.1])
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def func(x):
return sigmoid(np.dot(x, weights) + bias)
import hnumpy as hnp
import numpy as np