diff options
author | Tim Dettmers <tim.dettmers@gmail.com> | 2021-11-29 08:21:05 -0800 |
---|---|---|
committer | Tim Dettmers <tim.dettmers@gmail.com> | 2021-11-29 08:21:05 -0800 |
commit | 108cf9fc1f8c6bc0360a49ce790699928883b3d3 (patch) | |
tree | 57ed09eaa584f244f5376894504d2eb042372316 /bitsandbytes/optim | |
parent | b3fe8a6d0f53e3e81a4a6bc7385ce86077abf690 (diff) |
Fixed unsafe use of eval. #8
Diffstat (limited to 'bitsandbytes/optim')
-rw-r--r-- | bitsandbytes/optim/optimizer.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bitsandbytes/optim/optimizer.py b/bitsandbytes/optim/optimizer.py index 4b70b5c..cfbd72e 100644 --- a/bitsandbytes/optim/optimizer.py +++ b/bitsandbytes/optim/optimizer.py @@ -242,8 +242,9 @@ class Optimizer2State(Optimizer8bit): if not 0.0 <= eps: raise ValueError("Invalid epsilon value: {}".format(eps)) if isinstance(betas, str): - betas = eval(betas) - print(betas, 'parsed') + # format: '(beta1, beta2)' + betas = betas.replace('(', '').replace(')', '').strip().split(',') + betas = [float(b) for b in betas] for i in range(len(betas)): if not 0.0 <= betas[i] < 1.0: raise ValueError(f"Invalid beta parameter at index {i}: {betas[i]}") |