Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I wish to get raw probability distribution for the predicted classes. facing problems in using softmax #26

Open
ctsaurabhs opened this issue Sep 21, 2018 · 1 comment

Comments

@ctsaurabhs
Copy link

please help me, as how can I use softmax in place of argmax() to get raw probability distribution for the predicted classes

@changukshin
Copy link

changukshin commented Sep 21, 2018

The predictions operation is passed to process to the tensorflow session at line 63 of predict.py.
If you want to get the probability distribution of the classes, you can pass the operation you want to proceed.
The predictions operation is assigned at line 58 of predict.py.
Please search the probability operation of the network from text_cnn.py and pass the operation with predictions.

like

predictions = graph.get_operation_by_name("output/predictions").outputs[0]
scores = graph.get_operation_by_name("output/scores").outputs[0]

batches = ...
all_predictions = []
all_probabilities = []
for x_test_batch in batches:
    batch_predictions, batch_scores = sess.run([predictions, scores], {input_x: x_test_batch, dropout_keep_prob: 1.0})
    all_predictions = np.concatenate([all_predictions, batch_predictions])
    all_scores = np.concatenate([all_scores, batch_scores])

Note that above code is not tested. Please take a look at the predict.py line 58 ~ 64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants