Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
eaf21123
Commit
eaf21123
authored
Mar 28, 2022
by
A. Unique TensorFlower
Browse files
[dp] Decorate differential privacy configs w/ dataclass.
PiperOrigin-RevId: 437870878
parent
af1a6c57
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
official/modeling/privacy/configs.py
official/modeling/privacy/configs.py
+2
-0
official/modeling/privacy/configs_test.py
official/modeling/privacy/configs_test.py
+4
-4
No files found.
official/modeling/privacy/configs.py
View file @
eaf21123
...
@@ -13,10 +13,12 @@
...
@@ -13,10 +13,12 @@
# limitations under the License.
# limitations under the License.
"""Configs for differential privacy."""
"""Configs for differential privacy."""
import
dataclasses
from
official.modeling.hyperparams
import
base_config
from
official.modeling.hyperparams
import
base_config
@
dataclasses
.
dataclass
class
DifferentialPrivacyConfig
(
base_config
.
Config
):
class
DifferentialPrivacyConfig
(
base_config
.
Config
):
# Applied to the gradients
# Applied to the gradients
# Setting to a large number so nothing is clipped.
# Setting to a large number so nothing is clipped.
...
...
official/modeling/privacy/configs_test.py
View file @
eaf21123
...
@@ -29,10 +29,10 @@ class ConfigsTest(tf.test.TestCase):
...
@@ -29,10 +29,10 @@ class ConfigsTest(tf.test.TestCase):
self
.
assertEqual
(
0.0
,
noise_multiplier
)
self
.
assertEqual
(
0.0
,
noise_multiplier
)
def
test_config
(
self
):
def
test_config
(
self
):
dp_config
=
configs
.
DifferentialPrivacyConfig
(
{
dp_config
=
configs
.
DifferentialPrivacyConfig
(
'
clipping_norm
'
:
1.0
,
clipping_norm
=
1.0
,
'
noise_multiplier
'
:
1.0
noise_multiplier
=
1.0
,
}
)
)
self
.
assertEqual
(
1.0
,
dp_config
.
clipping_norm
)
self
.
assertEqual
(
1.0
,
dp_config
.
clipping_norm
)
self
.
assertEqual
(
1.0
,
dp_config
.
noise_multiplier
)
self
.
assertEqual
(
1.0
,
dp_config
.
noise_multiplier
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment