Closed zhaowenyi94 closed 7 years ago
Instead of reading data in binary mode (rb) you are now reading in text mode (r). On my machine the files are in binary format (I ran the download script in the data directory) and reading them in text mode would fail. I bet that's what's wrong: you read corrupt data.
btw I'm on an OSX machine.
I get the same performance ar the README:
traing iter: 598, test accuracy : 0.897862255573, loss : 0.568764030933
traing iter: 599, test accuracy : 0.899219572544, loss : 0.574430882931
final test accuracy: 0.899219572544
best epoch's test accuracy: 0.91177469492
I also use OSX, but I got an error if I use 'rb', did you went into this kind of error about and byte and string type?
File "/Users/zhaowenichi/Downloads/LSTM-Human-Activity-Recognition-master/lstm.py", line 205, in <module>
X_train = load_X(X_train_signals_paths)
File "/Users/zhaowenichi/Downloads/LSTM-Human-Activity-Recognition-master/lstm.py", line 41, in load_X
row.replace(' ', ' ').strip().split(' ') for row in file
File "/Users/zhaowenichi/Downloads/LSTM-Human-Activity-Recognition-master/lstm.py", line 41, in <listcomp>
row.replace(' ', ' ').strip().split(' ') for row in file
TypeError: a bytes-like object is required, not 'str'
Turns out the data files are in text format and not binary so your "r" solution should work.
I'm using python 2.7,.. are you using python 3.5/3.6?
I use the Python 3.5 :( Do not know how to fix it On Thu, Mar 2, 2017 at 9:51 PM Thijs van den Berg notifications@github.com wrote:
Turns out the data files are in text format and not binary so your "r" solution should work.
I'm using python 2.7,.. are you using python 3.5/3.6?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/guillaume-chevalier/LSTM-Human-Activity-Recognition/issues/8#issuecomment-283776161, or mute the thread https://github.com/notifications/unsubscribe-auth/AGr84vvo3rVlKJrQwlDJKyqGNX360g_Fks5rhyu6gaJpZM4MRMH9 .
strange, I have no problem with _file = open(signal_typepath, 'r') and python 3.5.2
The loss should not be negative for the cross entropy function since behind that is normally the label multiplying a log function of the prediction. That is a big hint.
The bug sits where you redefined the loss:
tf.nn.softmax_cross_entropy_with_logits(pred_Y, Y)) + l2 ===>>> tf.nn.softmax_cross_entropy_with_logits(labels=pred_Y,logits= Y)) + l2
Indeed the API changed. The order of the arguments is wrong compared to your call in the new version. You inverted things: logits are predictions, not the other way around as in the old TensorFlow r0.11 API: https://www.tensorflow.org/versions/r0.11/api_docs/python/nn/classification#softmax_cross_entropy_with_logits
Inverting those arguments seems to be a common mistake: https://github.com/carpedm20/NTM-tensorflow/issues/17
You still might have other problems hidden somewhere, I only took a quick look. I would not have expected the loss function to yield negative numbers either, but for that I am not sure because I have not re-validated the math of inverting the arguments.
Yes, modified and works! Thanks!
@zhaowenyi94 Hi! How did you modify?
To fit the current code in to the new released TensorFlow r1.0, I made several modification on the code
In the Loading Function
In the LSTM_NETWORK() Function
In main()
However, I ran the code and the performance does not seem good as it is shown in the readme file, I want to know whether the modification of the code have some mistakes. The results shown as below: