Skip to content

Commit 49f1ff7

Browse files
committed
set requires_grad depending on whether training or not
1 parent be2e021 commit 49f1ff7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setup(
44
name = 'vector_quantize_pytorch',
55
packages = find_packages(),
6-
version = '0.4.0',
6+
version = '0.4.1',
77
license='MIT',
88
description = 'Vector Quantization - Pytorch',
99
author = 'Phil Wang',

vector_quantize_pytorch/vector_quantize_pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def forward(self, x):
311311
if self.training:
312312
quantize = x + (quantize - x).detach()
313313

314-
loss = torch.tensor([0.], device = device)
314+
loss = torch.tensor([0.], device = device, requires_grad = self.training)
315315

316316
if self.training:
317317
if self.commitment > 0:

0 commit comments

Comments
 (0)