Output probabilities for each class on tensorflow sigmoid function I have a piece of code that uses tf.nn.softmax to predict whether does a image belongs to either class 0, 1, 2... etc. 

However, I want to edit the code to using sigmoid as the activation function and outputing all the probabilities, and setting those with probabilities >0.5 as one of the classes identified in the image. 

This is the code which I am trying to run: https://github.com/satyenrajpal/Concrete-Crack-Detection

I believe this is the code snippet where my edit should be made:

            for counter,image in enumerate(test_images):
                #break up images into 128*128
                broken_image,h,w,h_no,w_no = break_image(image,128)

                output_image = np.zeros((h_no*128,w_no*128,3),dtype = np.uint8)

                feed_dict = {x: broken_image}
                batch_predictions = sess.run(predictions, feed_dict = feed_dict)

                print("here is one loop")

                print(batch_predictions)

#                file = open("test.txt","w")
#                bpred_str = batch_predictions.astype('str')
#                file.write(bpred_str)
#                file.write(" ")
#                file.close()

                results=np.concatenate((results, batch_predictions))

                matrix_pred = batch_predictions.reshape((h_no,w_no))
                #Concentrate after this for post processing
                for i in range(0,h_no):
                    for j in range(0,w_no):
                        a = matrix_pred[i,j]
                        output_image[128*i:128*(i+1),128*j:128*(j+1),:] = 1-a

                cropped_image = image[0:h_no*128,0:w_no*128,:]                    
                pred_image = np.multiply(output_image,cropped_image)


I tried to print batch_predictions, but instead it prints out something like:

[1 1 0 1 1 0]


Another snippet is:

#Predict the class
y_pred = tf.nn.sigmoid(layer_fc2)
print("a: %s",y_pred)
#print("Class Probability: %s"%(sess.run(y_pred)))
self.y_pred_cls = tf.argmax(y_pred, dimension=1,name="predictions")

#Cost Function
cross_entropy = tf.nn.sigmoid_cross_entropy_with_logits(logits=layer_fc2, labels=self.y_true)
print("b: %s",cross_entropy)
cost = tf.reduce_mean(cross_entropy)
optimizer = tf.train.AdamOptimizer(learning_rate=1e-4).minimize(cost)

#Predict 
correct_prediction = tf.equal(self.y_pred_cls, self.y_true_cls)
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
probabilities=tf.nn.sigmoid(y_pred)
print("Class Probabilities: %s", probabilities)
return optimizer, accuracy


I also tried to print the output of tf.nn.sigmoid(y_pred), but it gave:

Class Probabilities: %s Tensor("Sigmoid_1:0", shape=(?, 2), dtype=float32)


I need help on how to print out the individual probabilities of the classes when I run the model on a unlabelled data. Thank you in advance!
You need to print output of sigmoid before tf.argmax is applied. It can be done with "tf.print", tf.print is a network node that does modify values. 

y_pred = tf.nn.sigmoid(layer_fc2)
y_pred = tf.print(y_pred ,[y_pred ])
self.y_pred_cls = tf.argmax(y_pred, dimension=1,name="predictions")


Docs : https://www.tensorflow.org/api_docs/python/tf/print