stock-trading-ml
stock-trading-ml copied to clipboard
ValueError
I am getting the following error when I run "python trading_algo.py"
2021-02-13 10:43:34.165315: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1
2021-02-13 10:43:36.611898: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-02-13 10:43:36.613079: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2021-02-13 10:43:36.635749: E tensorflow/stream_executor/cuda/cuda_driver.cc:328] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2021-02-13 10:43:36.635814: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (821e3f25af0b): /proc/driver/nvidia/version does not exist
2021-02-13 10:43:36.636356: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-02-13 10:43:37.423855: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2)
2021-02-13 10:43:37.424339: I tensorflow/core/platform/profile_utils/cpu_utils.cc:112] CPU Frequency: 2299995000 Hz
Traceback (most recent call last):
File "trading_algo.py", line 37, in
I get an error like this too. What should I do?
@linuxdebian @LeagueLugas this is already resolved in https://github.com/yacoubb/stock-trading-ml/issues/18#issuecomment-675791707:
i found the problem and the fix: In
predicted_price_tomorrow = np.squeeze(y_normaliser.inverse_transform(model.predict([[ohlcv], [ind]])))
,model.predict()
is expecting (in this case) a list of arrays. Instead, we are currently passing in a list of lists. To fix this, all you need to do is changemodel.predict([[ohlcv], [ind]])
tomodel.predict([np.array([ohlcv]), np.array([ind])])
I am getting a similar issue and I think it may be related to this.
I am getting the following error:
2021-06-25 15:23:09.091068: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll
2021-06-25 15:23:12.078912: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library nvcuda.dll
2021-06-25 15:23:12.112451: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1660 Ti with Max-Q Design computeCapability: 7.5
coreClock: 1.335GHz coreCount: 24 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 268.26GiB/s
2021-06-25 15:23:12.112576: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll
2021-06-25 15:23:12.121459: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublas64_11.dll
2021-06-25 15:23:12.121605: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublasLt64_11.dll
2021-06-25 15:23:12.125891: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cufft64_10.dll
2021-06-25 15:23:12.127195: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library curand64_10.dll
2021-06-25 15:23:12.137114: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusolver64_11.dll
2021-06-25 15:23:12.140947: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusparse64_11.dll
2021-06-25 15:23:12.142136: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found
2021-06-25 15:23:12.142194: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1766] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2021-06-25 15:23:12.142952: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-06-25 15:23:12.143771: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1258] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-06-25 15:23:12.143852: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1264]
2021-06-25 15:23:12.915007: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization Passes are enabled (registered 2)
Traceback (most recent call last):
File "trading_algo.py", line 22, in
C:\Users\Ruans\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\engine\training.py:1544 predict_function *
return step_function(self, iterator)
C:\Users\Ruans\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\engine\training.py:1527 run_step *
outputs = model.predict_step(data)
C:\Users\Ruans\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\engine\training.py:1500 predict_step *
return self(x, training=False)
C:\Users\Ruans\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\engine\base_layer.py:989 __call__ *
input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
C:\Users\Ruans\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\engine\input_spec.py:197 assert_input_compatibility *
raise ValueError('Layer ' + layer_name + ' expects ' +
ValueError: Layer model expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, 50, 5) dtype=float32>, <tf.Tensor 'IteratorGetNext:1' shape=(None, 1) dtype=float32>]
I have tried updating "y_test_predicted = model.predict([ohlcv_test, tech_ind_test])" to y_test_predicted = model.predict([np.array(ohlcv_test), np.array(tech_ind_test)])
@RuanSerfontein - what model.h5 are you using within the trading_algo.py file? I was using basic_model.h5 and it produced the "Layer model expects 1 input(s), but it received 2 input tensors" error. The reason is that trading_algo.py requires the technical indicator as well and that is only provided by the technical_model.h5. Hope this helps.