Restricting output classes in multi-class classification in Tensorflow -


i building bidirectional lstm multi-class sentence classification. have in total 13 classes choose , multiplying output of lstm network matrix dimensionality [2*num_hidden_unit,num_classes] , apply softmax probability of sentence fall 1 of 13 classes.

so if consider output[-1] network output:

w_output = tf.variable(tf.truncated_normal([2*num_hidden_unit,num_classes])) result = tf.matmul(output[-1],w_output) + bias

and [1, 13] matrix (assuming not working batches moment).

now, have information given sentence not fall given class sure , want restrict number of classes considered given sentence. let's instance given sentence, know can fall in 6 classes output should matrix of dimensionality [1,6].

one option thinking of put mask on result matrix multiply rows corresponding classes want keep 1 , ones want discard 0, in way lose of information instead of redirecting it.

anyone has clue on in case?

i think best bet is, seem have described, using weighted cross entropy loss function weights "impossible class" 0 , 1 other possible classes. tensorflow has weighted cross entropy loss function.

another interesting less effective method feed whatever information have classes sentence can/cannot fall network @ point (probably towards end).


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -