carpedm20 / lstm-char-cnn-tensorflow

in progress
MIT License
769 stars 243 forks source link

crushed when use both char and word #12

Closed stevesyang closed 8 years ago

stevesyang commented 8 years ago

hi carpedm20, When I set both "use_char" and "use_word" to True, program cannot run correctly: flags.DEFINE_boolean("use_char", True, "Use character-level language model [True]") flags.DEFINE_boolean("use_word", True, "Use word-level language [False]")

models/LSTMTDNN.py line 102: if self.use_char: char_W = tf.get_variable("char_embed", [self.char_vocab_size, self.char_embed_dim]) else: word_W = tf.get_variable("word_embed", [self.word_vocab_size, self.word_embed_dim])

should modified to: if self.use_char: char_W = tf.get_variable("char_embed", [self.char_vocab_size, self.char_embed_dim]) if self.use_word: word_W = tf.get_variable("word_embed", [self.word_vocab_size, self.word_embed_dim])

In addition, line 132(models/LSTMTDNN.py), is it a syntax error when using tf.concat: cnn_output = tf.concat(1, char_cnn.output, word_embed)

shoud it be modified to: cnn_output = tf.concat(1, [char_cnn.output, tf.squeeze(word_embed, [1])]) ?

carpedm20 commented 8 years ago

@stevesyang Thanks!