carpedm20 / lstm-char-cnn-tensorflow

in progress
MIT License
761 stars 243 forks source link

Dimension size must be evenly divisible by 21 but is 1 for 'LSTMTDNN/CNN/Reshape' (op: 'Reshape') with input shapes: [], [2]. #20

Open fengjiqiang opened 7 years ago

fengjiqiang commented 7 years ago

when run the 'main.py', encounter this problem.

dittaya commented 7 years ago

The problem may be the different version of Tensorflow API.

After

  1. Upgrading the codes (esp. LSTMDNN.py) to Tensorflow 1.0 using the script in https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/compatibility
  2. Redefining the _linear in ops.py and LSTMDNN.py Ref: http://stackoverflow.com/questions/42437115/tensorflow-replacement-for-tf-nn-rnn-cell-linearinput-size-0-scope
  3. Changing calls of tf.nn.rnn_cell to tf.contrib.rnn in LSTMDNN.py tf.nn.rnn_cell.BasicLSTMCell -> tf.contrib.rnn.BasicLSTMCell tf.nn.rnn_cell.MultiRNNCell -> tf.contrib.rnn.MultiRNNCell tf.nn.rnn -> tf.contrib.rnn.static_rnn

I can successfully run the code.

fengjiqiang commented 7 years ago

thanks

At 2017-04-12 15:49:52, "dittaya" notifications@github.com wrote:

The problem may be the different version of Tensorflow API.

After

Upgrading the codes (esp. LSTMDNN.py) to Tensorflow 1.0 using the script in https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/compatibility Redefining the _linear in ops.py and LSTMDNN.py Ref: http://stackoverflow.com/questions/42437115/tensorflow-replacement-for-tf-nn-rnn-cell-linearinput-size-0-scope Changing calls of tf.nn.rnn_cell to tf.contrib.rnn in LSTMDNN.py tf.nn.rnn_cell.BasicLSTMCell -> tf.contrib.rnn.BasicLSTMCell tf.nn.rnn_cell.MultiRNNCell -> tf.contrib.rnn.MultiRNNCell tf.nn.rnn -> tf.contrib.rnn.static_rnn

I can successfully run the code.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

liubin3701 commented 7 years ago

I met the same problem as you did when executing the paper code. Can you tell me how to modify the code in detail?

dittaya commented 7 years ago
  1. Run the script to upgrade the code
  2. Define _linear function (code copied from the this link) since the new Tensorflow library does not have it.
  3. Replace every tf.nn.rnn_cell with tf.contrib.rnn .. and so on.

However, the owner of the project stated that, with this code, this code couldn't reproduce the result in the paper. I've switched to this link instead.

liubin3701 commented 7 years ago

I used the new tf-lstm-char-enn code that you suggested, but the file '../lstm-char-cnn/paraminit.t7' could not be found.

dittaya commented 7 years ago

This codes and the new one does not required that file. I can just clone the repository and run their codes.