tensorflow pit Embedding+LSTM

1 When the label is input, if it is a two-category, one-dimensional can be used, and if it is a three-category, it must be three-dimensional.

Must be [1,0,0], [0,1,0], [0,1,1]

2 For predicted results

result_1 = model.predict(x_test)
 # is the classification, which dimension to output, this item is three types, output 0, 1, 2, 0 represents [1, 0, 0], 1 represents [0, 1, 0], 2 for [0,0,1]
 result_2 = model.predict_classes(x_test)

Note, say 12 test statements

result_1 result

00 = {ndarray} [0.2377571 0.12362082 0.63862205]
01 = {ndarray} [0.3286156 0.01859419 0.6527902]
02 = {ndarray} [0.05248537 0.8776761 0.06983855]
03 = {ndarray} [0.45481557 0.06610067 0.4790837]
04 = {ndarray} [0.46586016 0.28993273 0.2442071]
05 = {ndarray} [0.09239112 0.44054875 0.46706006]
06 = {ndarray} [0.10662748 0.5958726 0.29749998]
07 = {ndarray} [0.19824359 0.01758298 0.7841734]
088
3 0.8888888888888888888888888888884888888888
10 = {ndarray} [0.07185426 0.06959855 0.8585472]
11 = {ndarray} [0.02139795 0.89425915 0.08434288]

result_1 result

<class 'list'>: [2, 2, 1, 2, 0, 2, 1, 2, 2, 2, 2, 1]

It is not difficult to find that model.predict_classes is the classification result, which dimension belongs to, and it is calculated again on the basis of result_1.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325639848&siteId=291194637