I am using keras bi-lstm to predict 14 classes. Here is my label index:
label_index=`{'1':0,'2':1,'D':2,'7':3,'8':4,'9':5,'10':6,'11':7,'12':8,'13':9,'14':10,'15':11,'16':12,'17':13}`
Here is part of my model setting:
model.add(Bidirectional(LSTM(64)))
model.add(Dropout(0.5))
model.add(Dense(14, activation='softmax'))
model.compile('adam', 'sparse_categorical_crossentropy', metrics=['accuracy'])
The "14" in the Dense function is the number of classes. When I looked at the label distribution of pred = model.predict(x_test, verbose=0)
, I found this:
Counter({'1': 54,
'10': 88,
'11': 5,
'12': 2,
'13': 6,
'14': 5,
'3': 65,
'4': 5,
'5': 3,
'6': 28,
'7': 10,
'8': 3,
'9': 3})
Where did this "14" come from???? It's not in my index. And there was no "0"! I guess in the multi-class situation, kera.predict cannot output zero. Should I deduct 1 for every element in my "pred"?