You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I retrieve the output of the Dense layer (i.e., the result of the linear computation 𝑦 = 𝑚 𝑥 + 𝑐 y=mx+c) in the logistic regression model after loading it, and decrypt this output?
#1528
Open
danijimmy19 opened this issue
Nov 8, 2024
· 1 comment
I trained the logistic regression model using the MP-SPDZ library's ml.GDLogistic() function. After loading the trained model using the following code:
# load the model and the parameters
print_ln('load the trained model ...')
f = open('Player-Data/Binary-Output-P0-0')
lr_model = np.fromfile(f, "double", count=4) # where 30, 4, 784 is the shape of feature vector for 1 datapoint
log.opt.trainable_variables[0].assign(sfix.input_tensor_via(0, lr_model))
print_ln("weights:")
print_ln('%s', (log.opt.layers[0].W).reveal())
lr_bias = np.fromfile(f, "double", count=4)
log.opt.trainable_variables[1].assign(sfix.input_tensor_via(0, lr_bias))
print_ln("bias: ")
print_ln('%s', (log.opt.layers[0].b).reveal())
After loading the model, I compute the accuracy of the model. However, I want to access the output of the Dense layer, which is the linear combination of inputs and weights (i.e., y=mx+c). How can I get this linear output from the model and decrypt it?
Meaning, How can I compute the time for the logistic regression function where only the y=mx+c is computed and discard the final prediction layer?
Dense -> Sigmoid -> Output
How can I compute the time for only Dense layer here?
Time(Dense) -> Sigmoid -> Output
This below snippet will compute the time for Dense -> Sigmoid -> Output
The inputs and outputs to every layer are in the X and Y members, so you should able to find the intermediate results at log.opt.layers[0].Y.
For the timing, you can set log.opt.time_layers = True. This will use the timer 100+i for the i-th layer, i.e., timer 100 will measure the time for the linear layer.
I trained the logistic regression model using the MP-SPDZ library's ml.GDLogistic() function. After loading the trained model using the following code:
After loading the model, I compute the accuracy of the model. However, I want to access the output of the Dense layer, which is the linear combination of inputs and weights (i.e.,
y=mx+c
). How can I get this linear output from the model and decrypt it?Meaning, How can I compute the time for the logistic regression function where only the
y=mx+c
is computed and discard the final prediction layer?Dense -> Sigmoid -> Output
How can I compute the time for only
Dense
layer here?Time(Dense) -> Sigmoid -> Output
This below snippet will compute the time for Dense -> Sigmoid -> Output
The text was updated successfully, but these errors were encountered: