Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

How to use model.predict() in keras for NLP multilabel text classification?

$
0
0

@work.official wrote:

pad sequences so that we get N*T matrix

data_test = pad_sequences(sequences_test, maxlen=MAX_SEQUENCE_LENGTH)
print(‘Shape of a data tensor:’,data_test.shape)

Shape of a data tensor: (1953, 100)

prediction = model.predict(data_test)

prediction[:30]

[{“metadata”:{“trusted”:true,“scrolled”:true},“cell_type”:“code”,“source”:“prediction = model.predict(data_test)\n\nprediction[:30]”,“execution_count”:30,“outputs”:[{“output_type”:“execute_result”,“execution_count”:30,“data”:{“text/plain”:“array([[3.9713186e-01],\n [3.3080280e-03],\n [4.3809414e-06],\n [9.6850574e-01],\n [4.4691980e-02],\n [5.4853559e-03],\n [7.5977743e-03],\n [9.8550528e-01],\n [9.6740210e-01],\n [5.5730343e-06],\n [3.5762787e-07],\n [1.9733012e-03],\n [6.8902969e-05],\n [1.2275457e-02],\n [0.0000000e+00],\n [4.7802538e-02],\n [1.4237148e-01],\n [8.9472163e-01],\n [1.0897815e-03],\n [1.3554096e-04],\n [4.1053826e-01],\n [1.9013882e-05],\n [9.1195107e-06],\n [1.2386590e-02],\n [7.5763464e-04],\n [9.7979856e-01],\n [2.1308661e-05],\n [3.0400950e-01],\n [2.4541914e-03],\n [7.3269010e-03]], dtype=float32)”},“metadata”:{}}]}]

print(predict_classes([[2.2358119e-02,
6.3806772e-05]]))

o = np.argmax(prediction,axis=1)

I tried many ways, but all I am getting is zero output

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles