From b0d954c6e167d1780f6d76fba99df68fb43a7413 Mon Sep 17 00:00:00 2001 From: Ruijie Date: Tue, 4 Jun 2024 06:21:28 -0400 Subject: [PATCH] Fix bug in normalize to avoid divide by zero (#239) Co-authored-by: rj Co-authored-by: Remi --- lerobot/common/policies/normalize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerobot/common/policies/normalize.py b/lerobot/common/policies/normalize.py index d638c5416..9b055f7e6 100644 --- a/lerobot/common/policies/normalize.py +++ b/lerobot/common/policies/normalize.py @@ -147,7 +147,7 @@ class Normalize(nn.Module): assert not torch.isinf(min).any(), _no_stats_error_str("min") assert not torch.isinf(max).any(), _no_stats_error_str("max") # normalize to [0,1] - batch[key] = (batch[key] - min) / (max - min) + batch[key] = (batch[key] - min) / (max - min + 1e-8) # normalize to [-1, 1] batch[key] = batch[key] * 2 - 1 else: