Internal change.

PiperOrigin-RevId: 325249654
This commit is contained in:
A. Unique TensorFlower 2020-08-06 09:47:49 -07:00
parent 08f960a1af
commit efca03b593

View file

@ -14,6 +14,8 @@
# Lint as: python3
"""Tests for tensorflow_privacy.privacy.membership_inference_attack.data_structures."""
import os
import tempfile
from absl.testing import absltest
import numpy as np
from tensorflow_privacy.privacy.membership_inference_attack.data_structures import AttackInputData
@ -205,6 +207,17 @@ class AttackResultsTest(absltest.TestCase):
'Highest advantage on slice SingleSliceSpec(Entire dataset) achieved ' +
'by AttackType.THRESHOLD_ATTACK with an advantage of 0.0')
def test_save_load(self):
results = AttackResults(
[self.perfect_classifier_result, self.random_classifier_result])
with tempfile.TemporaryDirectory() as tmpdirname:
filepath = os.path.join(tmpdirname, 'results.pickle')
results.save(filepath)
loaded_results = AttackResults.load(filepath)
self.assertEqual(repr(results), repr(loaded_results))
if __name__ == '__main__':
absltest.main()