Morten Dahl, PhD and Datadog Machine Learning Engineer, from Aarhus University, explains how to implement a private deep learning model using a secure multi-party computing protocol. Inspired by a recent blog on hybrid deep learning and homomorphic encryption (see Numpy for homomorphic encryption neural networks), I thought it would be interesting to use secure multi-party computation instead of homomorphic encryption for deep learning.
In this article, we will build a simple secure multiparty computing protocol from scratch and then try to perform basic Boolean calculations based on it to train a simple neural network. The relevant code for this article can be found on GitHub (mortendahl/privateml/simple-boolean-functions). Suppose there are three parties P0, P1, and P2 that are not colluding, and they are willing to work together to train the neural network and use it for predictions; however, for some reason, they do not want to disclose the learned model. It is also assumed that some users are willing to provide training data while maintaining privacy, and some users are also interested in using well-learned models while their input remains private.
To achieve this, we need to safely calculate rational numbers with specific precision, specifically addition and multiplication. We also need to compute the sigmoid function 1/(1+np.exp(-x)). The traditional form of this function can lead to surprisingly heavy operations under security settings. Therefore, we will use a polynomial approximation of the sigmoid function, following the practice of homomorphic cryptographic neural networks based on Numpy, but with some optimization.
Secure multi-party computing (MPC) and homomorphic encryption (HE) are two closely related fields in modern cryptography. They often use each other's technology to solve roughly the same problem: computing functions on encrypted data without revealing anything except the final output. For example, in our private machine learning setup, both techniques can be used to train models and make predictions (although in the case of HE, if the data comes from users with different encryption keys, some special techniques are needed to handle).
From a high level, HE can often be replaced with MPC, and vice versa. At least for now, the difference between the two is that HE doesn't require much interaction but requires expensive calculations, while MPC's calculations are cheaper but require a lot of interaction. In other words, MPC replaces expensive calculations with interactions between two or more parties.
For now, this provides better performance in practice, so people can claim that MPC is a significantly more mature technology - as a basis for this assertion, there are already several companies offering MPC-based services.
Fixed point arithmetic is used to represent rational numbers as elements in a finite field. We will use a typical approach to amplify each rational number based on a fixed precision. For example, in the case of 6-bit precision, we will scale up by 10**6 and then represent the integer part of the result as a fixed-point number. For instance, when Q = 10000019, we get encode(0.5) == 500000 and encode(-0.5) == 10000019 - 500000 == 9500019.
Secret sharing is used to share data among parties while keeping it private. We will use replicated secret sharing, where each party receives multiple pieces of data. Specifically, the private value x is divided into parts x0, x1, x2, satisfying x == x0 + x1 + x2. The P0 side receives (x0, x1), P1 receives (x1, x2), and P2 receives (x2, x0). However, this will be implicit in this tutorial. This article will directly store the shared x as a three-part vector [x0, x1, x2].
Addition and subtraction can be performed locally by adding or subtracting the parts each party owns. Multiplication involves more complex steps, requiring communication between parties. After multiplication, we need to truncate the results to maintain precision.
A custom abstract data type is created to wrap these processes, allowing safe manipulation of values. Using this type, we can safely manipulate such values and switch to an unsafe type for debugging without modifying the rest of the code.
In deep learning, we focus on implementing a simple neural network using secure computations. The first experiment was to train the network to identify the first bit in the sequence. We used a two-layer network with a sigmoid approximation function. The second experiment involved a slightly more advanced function, which required an additional layer in the network.
We tried different approaches to approximate the sigmoid function, including polynomial interpolation, which improved the performance and stability of the network. Finally, we achieved better results with the interpolated polynomial approximation, showing that the network could learn the desired function and give correct predictions without revealing the input.
This article demonstrates that it is possible to implement private machine learning using very basic operations. While the focus was on a simple secure multiparty computing protocol, it is clear that more advanced protocols can further reduce the amount of data exchanged and improve overall performance. The integration of secure multiparty computing with machine learning processes requires expertise in both areas, but can significantly enhance the efficiency and effectiveness of the system.
Photovoltaic Single-Axis Tracking Bracket
Photovoltaic Single-Axis Tracking Bracket,One Axis Solar Tracker Solar,Solar Tracker Solar Racking Tracker,Solar Racking Tracker System Single-Axis
Hebei Shuobiao New Energy Technology Co., Ltd. , https://www.pvbracketsystem.com