tencia / stocks_rnn Goto Github PK
View Code? Open in Web Editor NEWStock price prediction with LSTMs in TensorFlow
License: Apache License 2.0
Stock price prediction with LSTMs in TensorFlow
License: Apache License 2.0
After a little modification to the source code as to adapt to the Tensorflow 1.0, I found the following error:
ValueError: Attempt to reuse RNNCell <tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl.BasicLSTMCell object at 0x1170bb710> with a different variable scope than its first use. First use of cell was with scope 'model/rnn/multi_rnn_cell/cell_0/basic_lstm_cell', this attempt is with scope 'model/rnn/multi_rnn_cell/cell_1/basic_lstm_cell'. Please create a new instance of the cell if you would like it to use a different set of weights. If before you were using: MultiRNNCell([BasicLSTMCell(...)] * num_layers), change to: MultiRNNCell([BasicLSTMCell(...) for _ in range(num_layers)]). If before you were using the same cell instance as both the forward and reverse cell of a bidirectional RNN, simply create two instances (one for forward, one for reverse). In May 2017, we will start transitioning this cell's behavior to use existing stored weights, if any, when it is called with scope=None (which can lead to silent model degradation, so this error will remain until then.)
And yet I have no idea how to fix it, hope anyone would hint me a little.
Below is my modification to the source.
from tensorflow.contrib import rnn
lstm_cell = rnn.BasicLSTMCell(hidden_size, forget_bias=0.0, state_is_tuple=True)
if is_training and config.keep_prob < 1:
lstm_cell = rnn.DropoutWrapper(lstm_cell, output_keep_prob=config.keep_prob)
cell = rnn.MultiRNNCell([lstm_cell for _ in range(config.num_layers)], state_is_tuple=True)
self._initial_state = cell.zero_state(batch_size, tf.float32)
iw = tf.get_variable("input_w", [1, hidden_size])
ib = tf.get_variable("input_b", [hidden_size])
inputs = [tf.nn.xw_plus_b(i_, iw, ib) for i_ in tf.split(self._input_data, num_steps, 1)]
if is_training and config.keep_prob < 1:
inputs = [tf.nn.dropout(input_, config.keep_prob) for input_ in inputs]
outputs, states = rnn.static_rnn(cell, inputs, initial_state=self._initial_state)
Can anyone provide a new version code?
(tensorflow) dhcp-v097-009:stocks_rnn-master Gene$ python train_stock_lstm.py
Traceback (most recent call last):
File "train_stock_lstm.py", line 13, in
from tensorflow.models.rnn import rnn
File "/Users/Gene/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/models/rnn/rnn.py", line 21, in
raise ImportError("This module is deprecated. Use tf.nn.rnn_* instead.")
ImportError: This module is deprecated. Use tf.nn.rnn_* instead.
My name is Luis, I'm a big-data machine-learning developer, I'm a fan of your work, and I usually check your updates.
I was afraid that my savings would be eaten by inflation. I have created a powerful tool that based on past technical patterns (volatility, moving averages, statistics, trends, candlesticks, support and resistance, stock index indicators).
All the ones you know (RSI, MACD, STOCH, Bolinger Bands, SMA, DEMARK, Japanese candlesticks, ichimoku, fibonacci, williansR, balance of power, murrey math, etc) and more than 200 others.
The tool creates prediction models of correct trading points (buy signal and sell signal, every stock is good traded in time and direction).
For this I have used big data tools like pandas python, stock market libraries like: tablib, TAcharts ,pandas_ta... For data collection and calculation.
And powerful machine-learning libraries such as: Sklearn.RandomForest , Sklearn.GradientBoosting, XGBoost, Google TensorFlow and Google TensorFlow LSTM.
With the models trained with the selection of the best technical indicators, the tool is able to predict trading points (where to buy, where to sell) and send real-time alerts to Telegram or Mail. The points are calculated based on the learning of the correct trading points of the last 2 years (including the change to bear market after the rate hike).
I think it could be useful to you, to improve, I would like to share it with you, and if you are interested in improving and collaborating I am also willing, and if not file it in the box.
If tou want, Please read the readme , and in case of any problem you can contact me ,
If you are convinced try to install it with the documentation.
https://github.com/Leci37/LecTrade/tree/develop I appreciate the feedback
state = m.initial_state.eval()
AttributeError: 'tuple' object has no attribute 'eval'
when the code runs here, it got the error as above, can't understand what does the author want to do here.
m.initial_state returns a tuple
Hi,
I am learning tensorflow and your example of stock prediction seems very interesting. I wonder, if you could guide in extending this example to provide vector of inputs. I made the following changes, but get error in matmul step.
I tried to change the code to input [x,x^2] instead of x, with following two lines of changes. But I get error.
in STOCKLSTM: self._input_data = tf.placeholder(tf.float32, [2, batch_size, num_steps])
In main/Epoch cost, state, _ = session.run([m.cost, m.final_state, eval_op], {m.input_data: (x,x**2), m.targets: y, m.initial_state: state})
ERROR:
ValueError: Cannot feed value of shape (2, 30, 10) for Tensor u'model/Placeholder:0', which has shape '(30, 10)'
Best,
self._final_state = states[-1]
this line in lstm.py file, line 153 !
could you tell me, how to fetch the status[-1] !
and what's the meaning of the statues !
thx !
in config.py
there is a param : names_file = 'data/dow30.csv' ;
so how can i find the file "dow30.csv"
thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.