Reputation: 1523
I want to setup a neuronal network and I am asking myself if there is a difference between those two functions?
tf.nn.tanh vs tf.tanh
Upvotes: 2
Views: 6096
Reputation: 19169
Easy enough to confirm they are the same:
In [1]: import tensorflow as tf
In [2]: tf.nn.tanh
Out[2]: <function tensorflow.python.ops.math_ops.tanh>
In [3]: tf.tanh
Out[3]: <function tensorflow.python.ops.math_ops.tanh>
In [4]: tf.nn.tanh == tf.tanh
Out[4]: True
In [5]: tf.__version__
Out[5]: '0.11.0rc1'
Upvotes: 5
Reputation: 81
No there isn't any difference.
The availability of both is probably due to the library evolving and still changing its API, being still in an initial state of maturing. We could expect the library to avoid those fundamental duplications in the future when the main API is finally set (I'd expect so towards 2.0).
Upvotes: 2
Reputation: 27042
No, there's no difference.
In the tensorflow/tensorflow/python/ops/nn.py
file (that's where tf.nn
is defined) we can find the definition of tanh
:
from tensorflow.python.ops.math_ops import tanh
also, there's this TODO
here
# TODO(cwhipkey): sigmoid and tanh should not be exposed from tf.nn.
Thus, probably tanh will be removed from the tf.nn
package.
Hence tf.tanh
(that's defined here) is the one to use.
Upvotes: 4
Reputation: 24581
They are the exact same alias to tensorflow.python.ops.math_ops.tanh
.
Same thing goes for tf.sigmoid
and tf.nn.sigmoid
.
Upvotes: 2