AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
10.19k stars 2.45k forks source link

numpy.linalg.LinAlgError: SVD did not converge #72

Closed AngelaChang119 closed 3 years ago

AngelaChang119 commented 3 years ago

I'm using a virtual environment of Python 3.7.3 in Mac 10.15.2 when I run python main.py --mode=train it returns

==============Start Feature Engineering=========== Successfully added technical indicators On entry to DLASCLS parameter number 4 had an illegal value On entry to DLASCLS parameter number 4 had an illegal value Traceback (most recent call last): File "main.py", line 53, in main() File "main.py", line 38, in main finrl.autotrain.training.train_one() File "/Users/angelachangi/Desktop/FinRL-Library/finrl/autotrain/training.py", line 36, in train_one processed = fe.preprocess_data(df) File "/Users/angelachangi/Desktop/FinRL-Library/finrl/preprocessing/preprocessors.py", line 53, in preprocess_data df = self.add_turbulence(df) File "/Users/angelachangi/Desktop/FinRL-Library/finrl/preprocessing/preprocessors.py", line 111, in add_turbulence turbulence_index = self.calculate_turbulence(df) File "/Users/angelachangi/Desktop/FinRL-Library/finrl/preprocessing/preprocessors.py", line 137, in calculate_turbulence temp = current_temp.values.dot(np.linalg.pinv(cov_temp)).dot( File "<__array_function__ internals>", line 6, in pinv File "/Users/angelachangi/Desktop/FinRL-Library/venv/lib/python3.7/site-packages/numpy/linalg/linalg.py", line 2003, in pinv u, s, vt = svd(a, full_matrices=False, hermitian=hermitian) File "<__array_function__ internals>", line 6, in svd File "/Users/angelachangi/Desktop/FinRL-Library/venv/lib/python3.7/site-packages/numpy/linalg/linalg.py", line 1661, in svd u, s, vh = gufunc(a, signature=signature, extobj=extobj) File "/Users/angelachangi/Desktop/FinRL-Library/venv/lib/python3.7/site-packages/numpy/linalg/linalg.py", line 97, in _raise_linalgerror_svd_nonconvergence raise LinAlgError("SVD did not converge") numpy.linalg.LinAlgError: SVD did not converge

AngelaChang119 commented 3 years ago

However, when I run with docker + ubuntu18.04 + python 3.6.9, the error message changes to

==============Start Feature Engineering=========== Successfully added technical indicators Traceback (most recent call last): File "main.py", line 53, in main() File "main.py", line 38, in main finrl.autotrain.training.train_one() File "/root/deepmodel/FinRL-Library/finrl/autotrain/training.py", line 36, in train_one processed = fe.preprocess_data(df) File "/root/deepmodel/FinRL-Library/finrl/preprocessing/preprocessors.py", line 53, in preprocess_data df = self.add_turbulence(df) File "/root/deepmodel/FinRL-Library/finrl/preprocessing/preprocessors.py", line 111, in add_turbulence turbulence_index = self.calculate_turbulence(df) File "/root/deepmodel/FinRL-Library/finrl/preprocessing/preprocessors.py", line 137, in calculate_turbulence temp = current_temp.values.dot(np.linalg.pinv(cov_temp)).dot( File "<__array_function__ internals>", line 6, in pinv File "/root/deepmodel/FinRL-Library/venv/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 2003, in pinv u, s, vt = svd(a, full_matrices=False, hermitian=hermitian) File "<__array_function__ internals>", line 6, in svd File "/root/deepmodel/FinRL-Library/venv/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 1661, in svd u, s, vh = gufunc(a, signature=signature, extobj=extobj) ValueError: On entry to DLASCL parameter number 4 had an illegal value

AngelaChang119 commented 3 years ago

Life is not easy, Angela sighs.

YangletLiu commented 3 years ago

Not sure why questioning about SVD?

wac81 commented 3 years ago

However, when I run with docker + ubuntu18.04 + python 3.6.9, the error message changes to

==============Start Feature Engineering=========== Successfully added technical indicators Traceback (most recent call last): File "main.py", line 53, in main() File "main.py", line 38, in main finrl.autotrain.training.train_one() File "/root/deepmodel/FinRL-Library/finrl/autotrain/training.py", line 36, in train_one processed = fe.preprocess_data(df) File "/root/deepmodel/FinRL-Library/finrl/preprocessing/preprocessors.py", line 53, in preprocess_data df = self.add_turbulence(df) File "/root/deepmodel/FinRL-Library/finrl/preprocessing/preprocessors.py", line 111, in add_turbulence turbulence_index = self.calculate_turbulence(df) File "/root/deepmodel/FinRL-Library/finrl/preprocessing/preprocessors.py", line 137, in calculate_turbulence temp = current_temp.values.dot(np.linalg.pinv(cov_temp)).dot( File "<array_function internals>", line 6, in pinv File "/root/deepmodel/FinRL-Library/venv/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 2003, in pinv u, s, vt = svd(a, full_matrices=False, hermitian=hermitian) File "<array_function internals>", line 6, in svd File "/root/deepmodel/FinRL-Library/venv/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 1661, in svd u, s, vh = gufunc(a, signature=signature, extobj=extobj) ValueError: On entry to DLASCL parameter number 4 had an illegal value

you can set use_turbulence=False to close compute turbulence