Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please help! AssertionError : assert state.shape == (args.state_dim,) #1226

Open
zhipentian opened this issue May 8, 2024 · 4 comments

Comments

@zhipentian
Copy link

Follow the tutorial https://github.com/AI4Finance-Foundation/FinRL-Tutorials/blob/master/3-Practical/FinRL_MultiCrypto_Trading.ipynb .
Always in:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2024.1\plugins\python-ce\helpers\pydev\pydevd.py", line 1535, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\JetBrains\PyCharm Community Edition 2024.1\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:\per\AI\test2\Crypto.py", line 44, in
train(start_date=TRAIN_START_DATE,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\per\AI\test2\traintest.py", line 72, in train
trained_model = agent.train_model(
^^^^^^^^^^^^^^^^^^
File "D:\per\AI\test2\elegantrl_models.py", line 107, in train_model
train_agent(model)
File "C:\Users\zhipe\AppData\Local\Programs\Python\Python311\Lib\elegantrl\train\run.py", line 35, in train_agent
assert state.shape == (args.state_dim,)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

@Faisalsouz
Copy link

same for me. please write back if you get answer: it look like that dimension model state is not matching with ENV state dimension

@Derek-yfqiu
Copy link

same for me...
it is an urgent issue to resolve

@DerekChu-YF
Copy link

Problem found:
in FinRL_MultiCrypto_Trading.ipynb :
model = agent.get_model(model_name, model_kwargs = erl_params)
it calles FinRL-Meta/agents/elegantrl_models.py:DRLAgent:get_model. This line set by default to the StockEnv
self.state_dim = 1 + 2 + 3 * stock_dim + self.tech_array.shape[1]
I change it to
self.state_dim = 1 + (self.price_array.shape[1] + self.tech_array.shape[1])#*lookback
and it works temporary.
I am able to train the model now

@zhipentian
Copy link
Author

Problem found: in FinRL_MultiCrypto_Trading.ipynb : model = agent.get_model(model_name, model_kwargs = erl_params) it calles FinRL-Meta/agents/elegantrl_models.py:DRLAgent:get_model. This line set by default to the StockEnv self.state_dim = 1 + 2 + 3 * stock_dim + self.tech_array.shape[1] I change it to self.state_dim = 1 + (self.price_array.shape[1] + self.tech_array.shape[1])#*lookback and it works temporary. I am able to train the model now

Thank you very much for your help. It seems that the problem has been solved. Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants