Kismuz / btgym

Scalable, event-driven, deep-learning-friendly backtesting library
https://kismuz.github.io/btgym/
GNU Lesser General Public License v3.0
984 stars 260 forks source link

ValueError: Shape must be rank 4 but is rank 3 for 'global/MaxPool' (op: 'MaxPool') with input shapes: [1,28,1]. #51

Closed gittrainee323 closed 6 years ago

gittrainee323 commented 6 years ago
Running environment:

OS: Ubuntu 16.0.4 tensorflow v1.7.0 Nvidia Driver Version: 390.48 Cuda : v9.1.85

Files or part of package has been run:

guided_a3c.py

Actual behaviour:

Traceback (most recent call last): File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 671, in _call_cpp_shape_fn_impl input_tensors_as_shapes, status) File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/contextlib.py", line 88, in exit next(self.gen) File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 4 but is rank 3 for 'global/MaxPool' (op: 'MaxPool') with input shapes: [1,28,1].

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/barry/Documents/Projects/Testing/btgym/btgym/algorithms/aac.py", line 405, in init self.network = self._make_policy('global') File "/home/barry/Documents/Projects/Testing/btgym/btgym/algorithms/aac.py", line 807, in _make_policy network = self.policy_class(self.policy_kwargs) File "/home/barry/Documents/Projects/Testing/btgym/btgym/research/gps/policy.py", line 31, in init kwargs File "/home/barry/Documents/Projects/Testing/btgym/btgym/algorithms/policy/stacked_lstm.py", line 460, in init super(AacStackedRL2Policy, self).init(kwargs) File "/home/barry/Documents/Projects/Testing/btgym/btgym/algorithms/policy/stacked_lstm.py", line 370, in init pixel_change_2d_estimator(ob_space['external'], kwargs) File "/home/barry/Documents/Projects/Testing/btgym/btgym/algorithms/nn/networks.py", line 249, in pixel_change_2d_estimator 'SAME' File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 1769, in max_pool name=name) File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 1605, in _max_pool data_format=data_format, name=name) File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op op_def=op_def) File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2508, in create_op set_shapes_for_outputs(ret) File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1873, in set_shapes_for_outputs shapes = shape_func(op) File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1823, in call_with_requiring return call_cpp_shape_fn(op, require_shape_fn=True) File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn debug_python_shape_fn, require_shape_fn) File "/home/barry/anaconda3/envs/A3C_LSTM/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 676, in _call_cpp_shape_fn_impl raise ValueError(err.message) ValueError: Shape must be rank 4 but is rank 3 for 'global/MaxPool' (op: 'MaxPool') with input shapes: [1,28,1].

Kismuz commented 6 years ago

@gittrainee323, sorry for late reply: Have you made any modifications to the code? Because I can't replicate the error - checked the notebook and it runs ok.

gittrainee323 commented 6 years ago

Hi, Kismuz Sorry for my late reply. The error has shown after I have updated the nvidia driver, cuda, tensorflow. Can help to share the tested version of nvidia driver, cuda, tensorflow? I will uninstall it and test it again. Thanks a million.

Kismuz commented 6 years ago

@gittrainee323 , it indeed may be the issue as I do not use GPU and have not tested btgym with cuda enabled.