healthDataScience / deep-learning-HAR

Convolutional and LSTM networks to classify human activity
457 stars 238 forks source link

regarding outputs, final_state = tf.contrib.rnn.static_rnn(cell, lstm_in, dtype=tf.float32,initial_state = initial_state) #4

Open wenouyang opened 6 years ago

wenouyang commented 6 years ago

Hi,

Thanks for sharing the code, but running the HAR-CNN_LSTM.ipynb, I got the following error message directly related to

with graph.as_default():
    outputs, final_state = tf.contrib.rnn.static_rnn(cell, lstm_in, dtype=tf.float32,
                                                     initial_state = initial_state)

The error message is as follows, would you like to take a look at it, and see how to fix it? Thanks. ValueError: Attempt to reuse RNNCell <tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl.BasicLSTMCell object at 0x2b53b31b2710> with a different variable scope than its first use. First use of cell was with scope 'rnn/multi_rnn_cell/cell_0/basic_lstm_cell', this attempt is with scope '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.)

bhimmetoglu commented 6 years ago

Thanks for reporting. This is a problem that appears with the latest tensorflow ( version >= 1.5), and I will update the code to fix it.

wenouyang commented 6 years ago

Hi, thank you for the reply. By the way, I was trying to adapt your model to some use cases I am interested. One observation for my use case is that the data set consists of very small values, such as -3.82587010e-11, The attached image shows an input vector example. Are there any recommendations to pre-process these vectors.

capture 1

bhimmetoglu commented 6 years ago

Maybe you can normalize these values by dividing with the max of the absolute value, or some other transformation that will re-scale the data into an interval [0,1]