Skip to content

Commit

Permalink
Models should not compute loss when encrypted backprop enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
james-choncholas committed Oct 30, 2024
1 parent da280db commit a1b9afa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tf_shell_ml/dpsgd_sequential_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ def rebalance(x, s):
for metric in self.metrics:
if metric.name == "loss":
if self.disable_encryption:
metric.update_state(0) # Loss is not known when encrypted.
else:
loss = self.loss_fn(y, y_pred)
metric.update_state(loss)
else:
metric.update_state(0) # Loss is not known when encrypted.
else:
if self.disable_encryption:
metric.update_state(y, y_pred)
Expand Down
4 changes: 2 additions & 2 deletions tf_shell_ml/postscale_sequential_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ def rebalance(x, s):
for metric in self.metrics:
if metric.name == "loss":
if self.disable_encryption:
metric.update_state(0) # Loss is not known when encrypted.
else:
loss = self.loss_fn(y, y_pred)
metric.update_state(loss)
else:
metric.update_state(0) # Loss is not known when encrypted.
else:
if self.disable_encryption:
metric.update_state(y, y_pred)
Expand Down

0 comments on commit a1b9afa

Please sign in to comment.