lilianweng / stock-rnn

Predict stock market prices using RNN model with multilayer LSTM cells + optional multi-stock embeddings.
https://lilianweng.github.io/lil-log
1.72k stars 656 forks source link

updates for python3 #11

Open andr3w321 opened 6 years ago

andr3w321 commented 6 years ago

Attached are my attempts at an update for compatibility with python3. The date_fetcher.py works fine, but when I run python main.py --stock_symbol=SP500 --train --input_size=1 --lstm_size=128 --max_epoch=50 I get the following error

$ python main.py --stock_symbol=SP500 --train --input_size=1 --lstm_size=128 --max_epoch=50 {'batch_size': 64, 'embed_size': None, 'init_epoch': 5, 'init_learning_rate': 0.001, 'input_size': 1, 'keep_prob': 0.8, 'learning_rate_decay': 0.99, 'lstm_size': 128, 'max_epoch': 50, 'num_layers': 1, 'num_steps': 30, 'sample_size': 4, 'stock_count': 100, 'stock_symbol': 'SP500', 'train': True} 2018-01-05 01:50:59.743127: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA /home/me/.virtualenvs/venv_stock_analysis/lib/python3.5/site-packages/tensorflow/python/ops/gradients_impl.py:96: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory. "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "

Variables: name (type shape) [size]

dynamic_rnn/lstm_cell/kernel:0 (float32_ref 129x512) [66048, bytes: 264192] dynamic_rnn/lstm_cell/bias:0 (float32_ref 512) [512, bytes: 2048] w:0 (float32_ref 128x1) [128, bytes: 512] b:0 (float32_ref 1) [1, bytes: 4] Total size of variables: 66689 Total bytes of variables: 266756 len(merged_test_X) = 0 len(merged_test_y) = 0 len(merged_test_labels) = 0 {'SP500': array([], dtype=float64)} Start training for stocks: ['SP500'] Traceback (most recent call last): File "main.py", line 112, in tf.app.run() File "/home/me/.virtualenvs/venv_stock_analysis/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "main.py", line 105, in main rnn_model.train(stock_data_list, FLAGS) File "/home/me/Dropbox/projects/stock-rnn/model_rnn.py", line 239, in train final_pred, final_loss = self.sess.run([self.pred, self.loss], test_data_feed) File "/home/me/.virtualenvs/venv_stock_analysis/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 889, in run run_metadata_ptr) File "/home/me/.virtualenvs/venv_stock_analysis/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1096, in _run % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (0,) for Tensor 'inputs:0', which has shape '(?, 30, 1)'