
### abstract_gradient_training/privacy_utils.py:81-153; SHA256 f89c6d610a4bca83717a482f7fbf1d87da5eb3e4c9d64a47d8f85aeb428171ce
81: 
82: def compute_max_certified_k(
83:     batch: torch.Tensor,
84:     bounded_model_dict: dict[int, BoundedModel],
85: ) -> torch.Tensor:
86:     """
87:     For each point in the input batch, compute the maximum of the given 'k_private' values such that the point is
88:     certified within the parameter bounds. param_bounds_dict is a dictionary of the form
89: 
90:         {k_private: bounded_model}
91: 
92:     where bounded_model contains bounds on the parameters trained via AGT for the given k_private value.
93:     The function returns a tensor of shape (batchsize, ) with the value of the largest k_private value for which
94:     each prediction is stable.
95: 
96:     Args:
97:         batch (torch.Tensor): Input batch of data (shape [batchsize, ...]).
98:         bounded_model_dict (dict[int, BoundedModel): Dictionary of k: bounded_model values obtained from AGT for varying
99:             values of k_private.
100: 
101:     Returns:
102:         torch.Tensor: The largest k_private value for which each point in the batch is certified.
103:     """
104:     # get the values of the nominal parameters from the first bounded model in the dict, which we will use for
105:     # validating each other bounded model has the same nominal parameters
106:     param_n_check = next(iter(bounded_model_dict.values())).param_n
107:     check_flag = False
108:     # initiate a store for the max k for which we can certify each point
109:     k_max = torch.zeros(batch.size(0), device=param_n_check[0].device)
110: 
111:     for k, bounded_model in bounded_model_dict.items():
112:         if not all(torch.allclose(a, b) for a, b in zip(bounded_model.param_n, param_n_check)):
113:             check_flag = True
114:         # check which points are certified for the given k_private value
115:         certified_points = test_metrics.certified_predictions(bounded_model, batch, return_proportion=False)
116:         k_max = torch.maximum(k_max, k * certified_points)  # update the max k for each point
117: 
118:     # warn the user if the nominal parameters don't match for all k_private values
119:     if check_flag:
120:         LOGGER.warning("Nominal parameters don't match for all k_private: check that you are seeding AGT correctly")
121: 
122:     # k_max now stores the max value of k for which we can certify each point.
123:     return k_max
124: 
125: 
126: def compute_smooth_sensitivity(
127:     beta: float,
128:     batch: torch.Tensor,
129:     bounded_model_dict: dict[int, BoundedModel],
130: ) -> torch.Tensor:
131:     """
132:     Compute the smooth sensitivity of the model predictions at each point in the test batch by bounding the following
133:     maximization problem:
134: 
135:         S(x) = max_{k_private} LS(x, k_private) exp(-beta * k_private)
136: 
137:     where LS(x, k_private) returns 1 if the point x is not certified for k_private, and 0 otherwise. The function is
138:     upper bounded by exp(-beta * k) for any k with LS(x, k) = 0.
139: 
140:     Args:
141:         beta (float): The beta-smooth sensitivity parameter.
142:         batch (torch.Tensor): Input batch of data (shape [batchsize, ...]).
143:         bounded_model_dict (dict[int, BoundedModel): Dictionary of k: bounded_model values obtained from AGT for varying
144:             values of k_private.
145: 
146:     Returns:
147:         torch.Tensor: A bound on the smooth sensitivity of the model predictions at each point in the test batch.
148:     """
149:     k_max = compute_max_certified_k(batch, bounded_model_dict)
150:     smooth_sensitivity = torch.exp(-beta * k_max)
151:     return smooth_sensitivity
152: 
153: 

### abstract_gradient_training/test_metrics.py:130-166; SHA256 e9c24a2670c7c187e0d7f7c4d3b99597ff3347dc8c9c6c371705beef6942ccbe
130: def certified_predictions(
131:     bounded_model: BoundedModel,
132:     batch: torch.Tensor,
133:     epsilon: float = 0.0,
134:     return_proportion=True,
135: ) -> torch.Tensor:
136:     """
137:     Given bounds on the parameters of a neural network, check whether each input in the batch has a constant prediction
138:     across all parameters in the bounds. If epsilon > 0, the proportion of certified points is certified for the given
139:     feature poisoning parameter.
140: 
141:     Args:
142:         bounded_model (BoundedModel): Bounded version of a pytorch model.
143:         batch (torch.Tensor): Input batch of data (shape [batchsize, ...]).
144:         epsilon (float, optional): Feature poisoning parameter.
145:         return_proportion (bool, optional): Flag to indicate if the proportion of certified points should be returned or
146:             the boolean tensor indicating whether each test point is certified.
147: 
148:     Returns:
149:         torch.Tensor: boolean tensor indicating whether each test point is certified or the proportion of certified
150:             points.
151:     """
152:     # validate input
153:     if epsilon < 0:
154:         raise ValueError("Feature poisoning parameter must be non-negative.")
155:     batch = batch.to(bounded_model.device).type(bounded_model.dtype)
156: 
157:     # get logit bounds
158:     logit_l, logit_u = bounded_model.bound_forward(batch - epsilon, batch + epsilon)
159:     logit_l = logit_l.squeeze() if logit_l.dim() > 1 else logit_l
160:     logit_u = logit_u.squeeze() if logit_u.dim() > 1 else logit_u
161: 
162:     if logit_l.dim() == 1:  # binary classification
163:         preds_l, preds_u = logit_l > 0, logit_u > 0
164:         certified_preds = preds_l == preds_u
165:         return certified_preds.float().mean() if return_proportion else certified_preds
166: 

### scripts/privacy_paper/dp_mechanisms.py:134-160; SHA256 6648b3b2547b95931aa97c736d861e42091d6fe3794c2d172dac8cd9b9297776
134: def predict_smooth_sens_cauchy(
135:     bounded_model_dict: dict[int, bounded_models.BoundedModel],
136:     batch: torch.Tensor,
137:     labels: torch.Tensor,
138:     epsilon: float | list[float],
139:     n_repeats: int = 1,
140: ) -> tuple[float, float] | list[tuple[float, float]]:
141:     """
142:     Compute the accuracy of the model on a batch of data with the Cauchy mechanism and the smooth sensitivity.
143:     """
144:     model = bounded_model_dict[0]
145:     predictions, labels = get_model_predictions(model, batch, labels)
146: 
147:     # compute the max certified distance
148:     max_k = privacy_utils.compute_max_certified_k(batch, bounded_model_dict)
149: 
150:     def private_prediction(eps: float) -> float:
151:         beta = eps / 6
152:         smooth_sens_bound = torch.exp(-beta * max_k).reshape(labels.shape)
153: 
154:         noise_distribution = torch.distributions.cauchy.Cauchy(0, 6 * smooth_sens_bound / eps + 1e-8)
155:         noise = noise_distribution.sample().to(predictions.device)
156:         assert predictions.shape == noise.shape
157:         private_predictions = (predictions + noise) > 0.5
158:         return (private_predictions == labels).float().mean().item()
159: 
160:     return handle_epsilon_list_and_repeats(private_prediction, epsilon, n_repeats)

### scripts/privacy_paper/single_model_plot_octmnist.py:44-51; SHA256 01336324f7181d38180797cb878cc580eaa325fa9e1e271a6a6da93a126d78c2
44: 
45: _, dataset_test_public = datasets.get_octmnist(exclude_classes=[2], encode=fixed_conv_layers)
46: _, dataset_test_drusen = datasets.get_octmnist(exclude_classes=[0, 1, 3], encode=fixed_conv_layers)
47: _, dataset_test_all = datasets.get_octmnist(encode=fixed_conv_layers)
48: ks_privacy = list(range(0, 50, 1)) + list(range(50, 201, 5))
49: ks_privacy = list(range(0, 10, 1)) + list(range(10, 50, 5)) + list(range(50, 201, 10))
50: cache_path = f"octmnist_{config.hash()}_{training_utils.hash_model(base_model)}_3"
51: 

### scripts/privacy_paper/single_model_plot_imdb.py:32-38; SHA256 afed4b2aeedef854e84111da180128f79d0d4b48350ff0f65ca1c8a8ef239155
32: )
33: 
34: _get_model = lambda seed: models.fully_connected(seed, width=100, depth=1, in_dim=768, out_dim=1)
35: 
36: ks_privacy = list(range(0, 50, 1)) + list(range(50, 201, 10))
37: dataset_train, dataset_test = datasets.get_imdb()
38: 

### abstract_gradient_training/training_utils.py:168-224; SHA256 9e59dc6028074004aaed21658e762e6bf002b5edeb022d6a88734a24c936458f
168: def dataloader_pair_wrapper(
169:     dl_train: Iterable, dl_aux: Iterable | None, n_epochs: int
170: ) -> Iterator[tuple[torch.Tensor, torch.Tensor, torch.Tensor | None, torch.Tensor | None]]:
171:     """
172:     Return a new generator that iterates over the training dataloaders for a fixed number of epochs.
173:     The first dataloader contains the standard training data, while the second dataloader contains auxiliary data,
174:     which is e.g. clean data for poisoning or public data for privacy.
175:     For each combined batch, we return one batch from the clean dataloader and one batch from the poisoned dataloader.
176:     This includes a check to ensure that each batch is full and ignore any incomplete batches.
177:     We assume the first batch is full to set the batchsize and this is compared with all subsequent batches.
178: 
179:     Args:
180:         dl_train (Iterable): Dataloader that returns (batch, labels) tuples at each iteration.
181:         dl_aux (Iterable | None): Optional additional dataloader for auxiliary data that returns (batch, labels)
182:             tuples at each iteration.
183:         n_epochs (int): Maximum number of epochs.
184: 
185:     Yields:
186:         batch, labels, batch_aux, labels_aux: Tuples of post-processed (batch, labels, batch_aux, labels_aux)
187:             for each iteration.
188:     """
189:     # batchsize variable will be initialised in the first iteration
190:     full_batchsize = None
191:     # loop over epochs
192:     for n in range(n_epochs):
193:         LOGGER.info("Starting epoch %s", n + 1)
194:         # handle the case where there is no auxiliary dataloader by returning dummy values
195:         if dl_aux is None:
196:             data_iterator: Iterable = (((b, l), (None, None)) for b, l in dl_train)
197:         else:
198:             data_iterator = zip(dl_train, dl_aux)  # note that zip will stop at the shortest iterator
199:         t = -1  # possibly undefined loop variable
200:         for t, ((batch, labels), (batch_aux, labels_aux)) in enumerate(data_iterator):
201:             batchsize = batch.size(0)
202:             if batch_aux is not None:
203:                 batchsize += batch_aux.size(0)
204:             # initialise the batchsize variable if this is the first iteration
205:             if full_batchsize is None:
206:                 full_batchsize = batchsize
207:                 LOGGER.debug("Initialising dataloader batchsize to %s", full_batchsize)
208:             # check the batch is the correct size, otherwise skip it
209:             if batchsize != full_batchsize:
210:                 LOGGER.debug(
211:                     "Skipping batch %s in epoch %s (expected batchsize %s, got %s)",
212:                     t + 1,
213:                     n + 1,
214:                     full_batchsize,
215:                     batchsize,
216:                 )
217:                 continue
218:             # return the batches for this iteration
219:             yield batch, labels, batch_aux, labels_aux
220:         # check the number of batches we have processed and report the appropriate warnings
221:         assert t != -1, f"Dataloader is empty at epoch {n + 1}!"
222:         if n == 0 and t == 0:
223:             LOGGER.info("Dataloader has only one batch per epoch, effective batchsize may be smaller than expected.")
224: 

### abstract_gradient_training/training_utils.py:236-261; SHA256 9e59dc6028074004aaed21658e762e6bf002b5edeb022d6a88734a24c936458f
236: def propagate_clipping(
237:     x_l: list[torch.Tensor], x: list[torch.Tensor], x_u: list[torch.Tensor], gamma: float, method: str
238: ) -> tuple[list[torch.Tensor], list[torch.Tensor], list[torch.Tensor]]:
239:     """
240:     Propagate the input through a clipping operation. This function is used to clip the gradients in the
241:     DP-SGD algorithm.
242: 
243:     Args:
244:         x_l (list[torch.Tensor]): Lower bound of the input tensors.
245:         x (list[torch.Tensor] | None): Optional nominal input tensor.
246:         x_u (list[torch.Tensor]): Upper bound of the input tensors.
247:         gamma (float): Clipping parameter.
248:         method (str): Clipping method, one of ["clamp", "norm"].
249: 
250:     Returns:
251:         list[torch.Tensor]: Lower bound on the clipped input tensor.
252:         list[torch.Tensor]: Nominal clipped input tensor.
253:         list[torch.Tensor]: Upper bound on the clipped input tensor.
254:     """
255:     if method == "clamp":
256:         interval_arithmetic.validate_interval(x_l, x_u, msg="input")
257:         x_l = [xi.clamp_(-gamma, gamma) for xi in x_l]
258:         x = [xi.clamp_(-gamma, gamma) for xi in x]
259:         x_u = [xi.clamp_(-gamma, gamma) for xi in x_u]
260:     elif method == "norm":
261:         interval_arithmetic.validate_interval(x_l, x_u, msg="input")

### abstract_gradient_training/gradient_accumulation.py:253-319; SHA256 98bd3cc1aa4114a7e592a3ee929a3aeae9c2de9eaee39117f8c48d79c63cb520
253:     def add_private_fragment_gradients(
254:         self, frag_grads_n: list[torch.Tensor], frag_grads_l: list[torch.Tensor], frag_grads_u: list[torch.Tensor]
255:     ) -> None:
256:         """
257:         Accumulate the gradients for a fragment of private data with the given bounds on the weight perturbed gradients.
258: 
259:         Args:
260:             frag_grads_n (list[torch.Tensor]): The nominal gradients for the fragment.
261:             frag_grads_l (list[torch.Tensor]): The lower bound gradients for the fragment with weight perturbation.
262:             frag_grads_u (list[torch.Tensor]): The upper bound gradients for the fragment with weight perturbation.
263:         """
264:         # validate the input
265:         interval_arithmetic.validate_interval(
266:             frag_grads_l, frag_grads_u, frag_grads_n, msg="grad bounds, private fragment"
267:         )
268:         for i in range(len(self.grads_n)):
269:             # accumulate the nominal gradients
270:             self.grads_n[i] += frag_grads_n[i].sum(dim=0)
271:             # take the top k lower bounds and bottom k upper bounds from the fragment
272:             k = min(frag_grads_l[i].size(0), self.k_private)
273:             l_top_k = torch.topk(frag_grads_l[i], k, largest=True, dim=0, sorted=False).values
274:             u_bottom_k = torch.topk(frag_grads_u[i], k, largest=False, dim=0, sorted=False).values
275:             # accumulate the rest of the gradients from the fragment to the bounds
276:             self.grads_l[i] += frag_grads_l[i].sum(dim=0) - l_top_k.sum(dim=0)
277:             self.grads_u[i] += frag_grads_u[i].sum(dim=0) - u_bottom_k.sum(dim=0)
278:             # now we concatenate the top/bottom k gradients from the fragment to the top/bottom k gradients we have seen
279:             frag_grads_l[i] = torch.cat([l_top_k, self.grads_l_top_k[i]], dim=0)
280:             frag_grads_u[i] = torch.cat([u_bottom_k, self.grads_u_bottom_k[i]], dim=0)
281:             # take the new top k lower bound gradients and bottom k upper bound gradients
282:             k = min(frag_grads_l[i].size(0), self.k_private)
283:             self.grads_l_top_k[i] = torch.topk(frag_grads_l[i], k, largest=True, dim=0, sorted=False).values
284:             self.grads_u_bottom_k[i] = torch.topk(frag_grads_u[i], k, largest=False, dim=0, sorted=False).values
285:             # accumulate the required sums to the bounds
286:             self.grads_l[i] += frag_grads_l[i].sum(dim=0) - self.grads_l_top_k[i].sum(dim=0)
287:             self.grads_u[i] += frag_grads_u[i].sum(dim=0) - self.grads_u_bottom_k[i].sum(dim=0)
288: 
289:     def concretize_gradient_update(
290:         self, batchsize: int
291:     ) -> tuple[list[torch.Tensor], list[torch.Tensor], list[torch.Tensor]]:
292:         """
293:         Compute the final gradient update rule, given all of the accumulated gradients for each fragment sent to this
294:         class during training.
295: 
296:             d_theta_l <- 1 / batchsize * (SEMin_{batchsize - k}(grad_wp_l) - k * gamma)
297:             d_theta_n <- 1 / batchsize * sum(grad_n)
298:             d_theta_u <- 1 / batchsize * (SEMax_{batchsize - k}(grad_wp_u) + k * gamma)
299: 
300:         Args:
301:             batchsize (int): The size of the batch.
302: 
303:         Returns:
304:             update_l: The lower bound on the descent direction.
305:             update_n: The nominal descent direction.
306:             update_u: The upper bound on the descent direction.
307:         """
308:         for i in range(len(self.grads_n)):
309:             assert self.grads_u_bottom_k[i].size(0) == self.k_private
310:             assert self.grads_l_top_k[i].size(0) == self.k_private
311:             self.grads_l[i] -= self.k_private * self.clip_gamma
312:             self.grads_u[i] += self.k_private * self.clip_gamma
313: 
314:         # normalise each by the batchsize
315:         update_l = [g / batchsize for g in self.grads_l]
316:         update_n = [g / batchsize for g in self.grads_n]
317:         update_u = [g / batchsize for g in self.grads_u]
318: 
319:         # clear the memory of this batch, and return the previous values

### abstract_gradient_training/privacy.py:35-63; SHA256 5cc423994de8b0d9b205cca09d8df107b21d5b2105465599a0ea490c30a1e042
35:         dl_val (Iterable): Iterable for the validation data that returns (batch, labels) tuples at each iteration. This
36:             data is used to log the performance of the model at each training iteration.
37:         dl_public (Iterable, optional): Iterable of data considered 'public' for the purposes of privacy certification.
38: 
39:     Returns:
40:         BoundedModel: The trained model with the final bounds on the parameters.
41:     """
42: 
43:     # initialise hyperparameters, model, data, optimizer, logging
44:     bounded_model.to(config.device)
45:     optimizer = config.get_bounded_optimizer(bounded_model)
46:     training_utils.log_run_start(config, agt_type="privacy")
47: 
48:     # initialise the gradient accumulation class, which handles the logic of accumulating gradients across batch
49:     # fragments and computing the certified descent direction bounds.
50:     gradient_accumulator = PrivacyGradientAccumulator(config.k_private, config.clip_gamma, bounded_model.param_n)
51: 
52:     # returns an iterator of length n_epochs x batches_per_epoch to handle incomplete batch logic
53:     training_iterator = training_utils.dataloader_pair_wrapper(dl_train, dl_public, config.n_epochs)
54:     val_iterator = training_utils.dataloader_cycle(dl_val) if dl_val is not None else None
55: 
56:     # main training loop
57:     for n, (batch, labels, batch_public, labels_public) in enumerate(training_iterator, 1):
58:         config.on_iter_start_callback(bounded_model)
59:         # possibly terminate early
60:         if config.early_stopping_callback(bounded_model):
61:             break
62: 
63:         # evaluate the network on the validation data and log the result

### abstract_gradient_training/privacy.py:94-121; SHA256 5cc423994de8b0d9b205cca09d8df107b21d5b2105465599a0ea490c30a1e042
94:         # process the "private" data, taking the appropriate bounds
95:         # split the batch into fragments to avoid running out of GPU memory
96:         batch_fragments = torch.split(batch, config.fragsize, dim=0)
97:         label_fragments = torch.split(labels, config.fragsize, dim=0)
98:         for batch_frag, label_frag in zip(batch_fragments, label_fragments):
99:             # compute the nominal gradients
100:             frag_grads_n = training_utils.compute_batch_gradients(
101:                 bounded_model, batch_frag, label_frag, config, nominal=True
102:             )
103:             # compute the weight perturbed bounds
104:             frag_grads_l, frag_grads_u = training_utils.compute_batch_gradients(
105:                 bounded_model, batch_frag, label_frag, config, nominal=False
106:             )
107:             # apply gradient clipping
108:             frag_grads_l, frag_grads_n, frag_grads_u = training_utils.propagate_clipping(
109:                 frag_grads_l, frag_grads_n, frag_grads_u, config.clip_gamma, config.clip_method
110:             )
111:             # accumulate the gradients
112:             gradient_accumulator.add_private_fragment_gradients(frag_grads_n, frag_grads_l, frag_grads_u)
113:             # the gpu memory allocations at each loop are not always collected, so we'll prompt pytorch to do so
114:             gc.collect()
115:             torch.cuda.empty_cache()
116: 
117:         # get the bounds on the descent direction, validate them, and apply the optimizer update
118:         batchsize = batch.size(0) if batch_public is None else batch.size(0) + batch_public.size(0)
119:         update_l, update_n, update_u = gradient_accumulator.concretize_gradient_update(batchsize)
120:         interval_arithmetic.validate_interval(update_l, update_u, update_n, "final_grad_bounds")
121:         optimizer.step(update_l, update_n, update_u)

### abstract_gradient_training/bounded_losses/binary_cross_entropy.py:185-201; SHA256 b4df17c781bec606d6512c855e6609791a0537746b651a4a21542d3beb6e7051
185:             raise RuntimeError(f"Logits shape {inputs_l.shape} does not match targets {targets.shape} for BCE.") from e
186:         interval_arithmetic.validate_interval(inputs_l, inputs_u, msg="loss input bounds")
187: 
188:         if label_k_poison != 0:  # label flipping case
189:             grad_l = (torch.sigmoid(inputs_l) - 1).reshape(input_shape)
190:             grad_u = (torch.sigmoid(inputs_u) - 0).reshape(input_shape)
191:         else:  # un-poisoned labels
192:             grad_l = (torch.sigmoid(inputs_l) - targets).reshape(input_shape)
193:             grad_u = (torch.sigmoid(inputs_u) - targets).reshape(input_shape)
194:         interval_arithmetic.validate_interval(grad_l, grad_u, msg="loss grad bounds")
195: 
196:         if self.reduction == "mean":
197:             LOGGER.warning("AGT processes grads in fragments, so using 'reduction=mean' is not recommended.")
198:             LOGGER.warning("Specify 'reduction=none' and normalise manually to ensure correct scaling.")
199:             return grad_l / grad_l.nelement(), grad_u / grad_u.nelement()
200:         return grad_l, grad_u
201: 

### abstract_gradient_training/bounded_optimizers/bounded_sgd.py:65-106; SHA256 f73906ad4c29590b509712db74f0a44233d058723559817fb75d9d3e0946c7bd
65:     def step(
66:         self, mean_grads_l: list[torch.Tensor], mean_grads_n: list[torch.Tensor], mean_grads_u: list[torch.Tensor]
67:     ):
68:         """
69:         Apply a sound SGD update the parameters and their bounds.
70: 
71:         Args:
72:             mean_grads_l (list[torch.Tensor]): Lower bound on the mean gradient of the batch.
73:             mean_grads_n (list[torch.Tensor]): Nominal mean gradient of the batch.
74:             mean_grads_u (list[torch.Tensor]): Upper bound on the mean gradient of the batch.
75: 
76:         Returns:
77:             tuple: The updated parameter lists [param_l, param_n, param_u].
78:         """
79:         # compute the new learning rate
80:         lr = self.lr_scheduler(self.step_count)
81: 
82:         # validate the gradient interval and shapes
83:         for i in range(len(mean_grads_n)):
84:             if mean_grads_n[i].shape != self.param_n[i].shape:
85:                 raise ValueError(
86:                     f"Gradient shape mismatch. Expected {self.param_n[i].shape}, got {mean_grads_n[i].shape}."
87:                 )
88:             interval_arithmetic.validate_interval(mean_grads_l[i], mean_grads_u[i], mean_grads_n[i], msg="pre sgd")
89: 
90:         # apply l2 regularization
91:         if self.l2_reg > 0:
92:             mean_grads_l = [g + self.l2_reg * p for g, p in zip(mean_grads_l, self.param_u)]
93:             mean_grads_n = [g + self.l2_reg * p for g, p in zip(mean_grads_n, self.param_n)]
94:             mean_grads_u = [g + self.l2_reg * p for g, p in zip(mean_grads_u, self.param_l)]
95: 
96:         # apply l1 regularization
97:         if self.l1_reg > 0:
98:             self.l1_update()
99: 
100:         for i in range(len(mean_grads_n)):
101:             # apply the parameter update
102:             self.param_n[i] -= lr * mean_grads_n[i]
103:             self.param_l[i] -= lr * mean_grads_u[i]
104:             self.param_u[i] -= lr * mean_grads_l[i]
105:             interval_arithmetic.validate_interval(self.param_l[i], self.param_u[i], self.param_n[i], msg="post sgd")
106: 

### scripts/privacy_paper/training_utils.py:135-146; SHA256 8dfcf8b8ac23a048386644120d2c72156cc627ec636d3af3b6824fdd79571994
135:             print(fname)
136:         return bounded_model
137: 
138:     assert not config.k_unlearn and not config.k_poison and not config.label_k_poison
139:     assert config.noise_multiplier == 0.0
140:     dataloader = torch.utils.data.DataLoader(dataset_train, batch_size=config.batchsize, shuffle=True)
141:     dataloader_test = (
142:         torch.utils.data.DataLoader(dataset_test, batch_size=10000, shuffle=True) if dataset_test else None
143:     )
144:     torch.manual_seed(config.seed)
145:     agt.privacy_certified_training(bounded_model, config, dataloader, dl_val=dataloader_test)
146:     if cache_path:
