adeshpande3 / LSTM-Sentiment-Analysis

Sentiment Analysis with LSTMs in Tensorflow
MIT License
979 stars 432 forks source link

Adaptation for multiclass classification #18

Closed dotjrt closed 6 years ago

dotjrt commented 6 years ago

Working through the tutorial while trying to implement the same general architecture for a multiclass classifier. Is there anything specific that needs to be changed to make it work other than setting the numClasses variable and setting the label vectors appropriately? Mainly wondering if the value = tf.transpose(value, [1, 0, 2]) operation after setting the weight matrix and bias needs to be changed in any way? Thanks in advance.

adeshpande3 commented 6 years ago

I believe those two changes should be enough. The tf.transpose operation shouldn't be affected. The purpose of that operation is to turn the volume from [batch_size, time_step, lstm_output_dim] into [time_step, batch_size, lstm_output_dim], and then to get the last hidden state vector in the following line, so the number of classes won't affect that.

You can also check out this post for more info on Tensorflow LSTMs and related operations.