quantylab / rltrader

파이썬과 케라스를 이용한 딥러닝/강화학습 주식투자 - 퀀트 투자, 알고리즘 트레이딩을 위한 최첨단 해법 입문 (개정판)
https://contents.premium.naver.com/misoncorp/quantylab
MIT License
353 stars 360 forks source link

main.py가 실행이 안됩니다. #86

Open hola-ai opened 3 years ago

hola-ai commented 3 years ago

아래의 명령으로 실행했습니다. python main.py --stock_code 005930 005380 015760 --rl_method a3c --net lstm --num_steps 5 --learning --num_epoches 1000 --lr 0.001 --start_epsilon 1 --discount_factor 0.9 --output_name train --start_date 20170101 --end_date 20181231

에러 메세지는 아래와 같습니다. From /home/justin/tt/rltrader/networks.py:25: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

2021-03-11 17:05:17.985730: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2021-03-11 17:05:18.005756: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3600000000 Hz 2021-03-11 17:05:18.006034: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5634039255c0 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2021-03-11 17:05:18.006052: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version From /home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/initializers.py:143: calling RandomNormal.init (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version. Instructions for updating: Call initializer instance with the dtype argument instead of passing it to the constructor From /home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/ops/resource_variable_ops.py:1630: calling BaseResourceVariable.init (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version. Instructions for updating: If using Keras pass *_constraint arguments to layers. Traceback (most recent call last): File "main.py", line 163, in 'policy_network_path': policy_network_path}) File "/home/justin/tt/rltrader/learners.py", line 533, in init input_dim=self.num_features) File "/home/justin/tt/rltrader/networks.py", line 82, in get_shared_network Input((num_steps, input_dim))) File "/home/justin/tt/rltrader/networks.py", line 164, in get_network_head kernel_initializer='random_normal')(inp) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/recurrent.py", line 623, in call return super(RNN, self).call(inputs, *kwargs) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 854, in call outputs = call_fn(cast_inputs, args, kwargs) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/recurrent.py", line 2549, in call inputs, mask=mask, training=training, initial_state=initial_state) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/recurrent.py", line 682, in call inputs, initial_state, constants) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/recurrent.py", line 798, in _process_inputs initial_state = self.get_initial_state(inputs) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/recurrent.py", line 606, in get_initial_state inputs=None, batch_size=batch_size, dtype=dtype) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/recurrent.py", line 2314, in get_initial_state self, inputs, batch_size, dtype)) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/recurrent.py", line 2752, in _generate_zero_filled_state_for_cell return _generate_zero_filled_state(batch_size, cell.state_size, dtype) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/recurrent.py", line 2768, in _generate_zero_filled_state return nest.map_structure(create_zeros, state_size) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/util/nest.py", line 536, in map_structure structure[0], [func(x) for x in entries], File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/util/nest.py", line 536, in structure[0], [func(x) for x in entries], File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/recurrent.py", line 2765, in create_zeros return array_ops.zeros(init_state_size, dtype=dtype) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 2338, in zeros output = _constant_if_small(zero, shape, dtype, name) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 2295, in _constant_if_small if np.prod(shape) < 1000: File "<__array_function__ internals>", line 6, in prod File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 3031, in prod keepdims=keepdims, initial=initial, where=where) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 87, in _wrapreduction return ufunc.reduce(obj, axis, dtype, out, passkwargs) File "/home/justin/anaconda3/envs/rlt/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 736, in array " array.".format(self.name)) NotImplementedError: Cannot convert a symbolic Tensor (lstm/strided_slice:0) to a numpy array.

quantylab commented 3 years ago

@udp-justin-lee

python 3.6 + cuda 10.0 + cudnn 7.3.1 로 시도해 보시길 권해드립니다. GPU 사용가능하시면 다음과 같이 환경 만드시면 됩니다.

conda create -n rltrader python=3.6
conda activate rltrader
pip install tensorflow-gpu==1.15
conda install cudatoolkit=10.0
conda install cudnn=7.3.1
pip install numpy
pip install pandas