What's difference between tf.sub and just minus operation in tensorflow?

Yes, - and + resolve to tf.sub ad tf.add. If you look at the tensorflow code you will see that these operators on tf.Variable are overloaded with the tf.* methods.

As to why both exists I assume the tf.* ones exist for consistency. So sub and say matmul operation can be used in the same way. While the operator overloading is for convenience.


(tf.sub appears to have been replaced with tf.subtract)

The only advantage I see is that you can specify a name of the operation as in:

tf.subtract(train, W1, name='foofoo')

This helps identify the operation causing an error as the name you provide is also shown:

ValueError: Dimensions must be equal, but are 28 and 40 for 'foofoo' (op: 'Sub') with input shapes

it may also help with TensorBoard understanding. It might be overkill for most people as python also shows the line number which triggered the error.