X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=pysvrt.git;a=blobdiff_plain;f=svrtset.py;h=40227523085908aeedeca74b97e888b42da4c593;hp=ecbaa68b992b81c20ba6a2874a4a74152e78566e;hb=8c709c982d64948ab1c8949930dc0468f91039aa;hpb=a500b3545f6eb25c480e945f2e12786933c92423 diff --git a/svrtset.py b/svrtset.py index ecbaa68..4022752 100755 --- a/svrtset.py +++ b/svrtset.py @@ -114,8 +114,17 @@ class CompressedVignetteSet: for b in range(0, self.nb_batches): target = torch.LongTensor(self.batch_size).bernoulli_(0.5) input = svrt.generate_vignettes(problem_number, target) - acc += float(input.sum()) / input.numel() - acc_sq += float((input * input).sum()) / input.numel() + + # FIXME input_as_float should not be necessary but there + # are weird memory leaks going on, which do not seem to be + # my fault + if b == 0: + input_as_float = input.float() + else: + input_as_float.copy_(input) + acc += input_as_float.sum() / input.numel() + acc_sq += input_as_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)