Closed lreaderl closed 6 years ago
Specifically, in p7_TextCNN_train.py, line88:
feed_dict[textCNN.input_y] = trainY[start:end]
It wouldn't work, anyway.
I solved by using get_target_label_short function.
I met it too, how you using get_target_label_short function? thanks @lreaderl
trainY = [] for it in trainY[start:end]: trainY.append(int(get_target_labelshort1(it))) trainY = np.array(trainY_,dtype=np.int32).flatten() feed_dict[textCNN.inputy] = trainY
get_target_label_short1() returns index
when using "tf.nn.sparse_softmax_cross_entropy_with_logits()",the length of “logits“ needs to be one dimensional more than ”labels“, you can modify this:
losses = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=self.input_y, logits=self.logits)
to : losses = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=tf.argmax(self.input_y, 1), logits=self.logits)
ValueError: Cannot feed value of shape (64, 19) for Tensor 'input_y:0', which has shape '(?,)' In textCNN, input_y is defined as [None,]. However, when feed it at train.py(feed_dict[textCNN.input_y] = trainY[start:end]), there is a problem occurred as below.