# Tensorflow Calculate error for a single neuron

I'm required to be able to calculate the error on a given neuron in a neural network using Tensorflow.

Using this :

mse = tf.reduce_mean(tf.squared_difference(out, Y))


i just get the updated weight, how i can get or calculate the error for each neuron in my network.

Thanks for the replies.

• To calculate error the true value is needed. Therefore you need the true value of each neuron in the network to calculate the error, which is probably not possible. Aug 4, 2018 at 0:17

Easy, you have already done it.

mse = tf.reduce_mean(tf.squared_difference(out, Y))

This command means you are taking the mean of all the neurons over all the examples.

error = tf.squared_difference(out, Y)

This command will give you the error over all neurons over all examples. But make sure you calculate against the correct axes.

• Can you explain more please,How to access to the neuron error ? Jul 4, 2018 at 22:08
• @lafiraed what exactly do you mean access? if you are looking to print it then print(error.eval()) inside a session should work fine Jul 5, 2018 at 16:49
• assume we have one hidden layer that have 20 neuron, i need to get the error for each neuron? Jul 5, 2018 at 17:34
• @lafiraed what? If you show me any equation or book that shows how to calculate errors for hidden layer then I'll tell you how to get it Jul 5, 2018 at 17:39
• no sorry i don't have it! Jul 5, 2018 at 17:45