X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=pysvrt.git;a=blobdiff_plain;f=svrtset.py;h=49f32799da7b0ba4a880d9aacc90278617908220;hp=cbc71a373237356007bca386de4890036ac902e5;hb=e754d1075d8d0a5949e71f426ab07ce73be6099e;hpb=b6cc25f4622917b0025d613d617b5ce9e23f07e9 diff --git a/svrtset.py b/svrtset.py index cbc71a3..49f3279 100755 --- a/svrtset.py +++ b/svrtset.py @@ -41,7 +41,7 @@ def generate_one_batch(s): class VignetteSet: - def __init__(self, problem_number, nb_samples, batch_size, cuda = False): + def __init__(self, problem_number, nb_samples, batch_size, cuda = False, logger = None): if nb_samples%batch_size > 0: print('nb_samples must be a multiple of batch_size') @@ -61,6 +61,7 @@ class VignetteSet: self.data = [] for b in range(0, self.nb_batches): self.data.append(generate_one_batch(mp_args[b])) + if logger is not None: logger(self.nb_batches * self.batch_size, b * self.batch_size) # Weird thing going on with the multi-processing, waiting for more info @@ -88,7 +89,7 @@ class VignetteSet: ###################################################################### class CompressedVignetteSet: - def __init__(self, problem_number, nb_samples, batch_size, cuda = False): + def __init__(self, problem_number, nb_samples, batch_size, cuda = False, logger = None): if nb_samples%batch_size > 0: print('nb_samples must be a multiple of batch_size') @@ -111,6 +112,7 @@ class CompressedVignetteSet: acc_sq += input.float().pow(2).sum() / input.numel() self.targets.append(target) self.input_storages.append(svrt.compress(input.storage())) + if logger is not None: logger(self.nb_batches * self.batch_size, b * self.batch_size) self.mean = acc / self.nb_batches self.std = sqrt(acc_sq / self.nb_batches - self.mean * self.mean)