gsyyysg / StockFormer

PyTorch implementation for Paper "StockFormer: Learning Hybrid Trading Machines with Predictive Coding".
207 stars 52 forks source link

python train_rl.py 有错 #6

Open lzmax888 opened 3 months ago

lzmax888 commented 3 months ago

root@C.10399061:/StockFormer/code$ python train_rl.py The Zen of Python, by Tim Peters

Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than right now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! generate technical indicator... Successfully added technical indicators Stock Dimension: 88, State Space: 88 Initial Env... Successfully load prediction mode... Transformer/pretrained/csi/Short/checkpoint.pth Successfully load prediction mode... Transformer/pretrained/csi/Long/checkpoint.pth Successfully load prediction mode... Transformer/pretrained/csi/Short/checkpoint.pth Successfully load prediction mode... Transformer/pretrained/csi/Long/checkpoint.pth Successfully load prediction mode... Transformer/pretrained/csi/Short/checkpoint.pth Successfully load prediction mode... Transformer/pretrained/csi/Long/checkpoint.pth Successfully load prediction mode... Transformer/pretrained/csi/Short/checkpoint.pth Successfully load prediction mode... Transformer/pretrained/csi/Long/checkpoint.pth {'batch_size': 32, 'buffer_size': 100000, 'learning_rate': 0.0001, 'learning_starts': 100, 'ent_coef': 'auto_0.1', 'enc_in': 96, 'dec_in': 96, 'c_out_construction': 96, 'd_model': 128, 'd_ff': 256, 'n_heads': 4, 'e_layers': 2, 'd_layers': 1, 'dropout': 0.05, 'transformer_path': 'Transformer/pretrained/csi/mae/checkpoint.pth'} Using cuda device Traceback (most recent call last): File "/StockFormer/code/train_rl.py", line 205, in model_sac = agent.get_model("maesac",model_kwargs = MAESAC_PARAMS,tensorboard_log=tensorboard_log_dir, seed=fix_seed) File "/StockFormer/code/MySAC/models/DRLAgent.py", line 135, in get_model model = MODELS[model_name]( File "/StockFormer/code/MySAC/SAC/MAE_SAC.py", line 163, in init self._setup_model() File "/StockFormer/code/MySAC/SAC/MAE_SAC.py", line 195, in _setup_model super(SAC, self)._setup_model() File "/StockFormer/code/MySAC/SAC/off_policy_algorithm.py", line 179, in _setup_model self.set_random_seed(self.seed) File "/StockFormer/code/stable_baselines3/common/base_class.py", line 567, in set_random_seed self.env.seed(seed) File "/StockFormer/code/stable_baselines3/common/vec_env/base_vec_env.py", line 278, in seed return self.venv.seed(seed) File "/StockFormer/code/stable_baselines3/common/vec_env/dummy_vec_env.py", line 56, in seed seeds.append(env.seed(seed + idx)) AttributeError: 'StockTradingEnv' object has no attribute 'seed'. Did you mean: '_seed'?

hugo2046 commented 3 months ago

我也是这个报错,请问解决了吗

hugo2046 commented 3 months ago

把_seed方法改为seed同时把init中的self._seed改为self._seed就行了

rl3250 commented 2 months ago

把_seed方法改为seed同时把init中的self._seed改为self._seed就行了

请问是在哪个文件里改?

decker502 commented 1 month ago

code/envs/env_stocktrading_hybrid_control.py 这个文件