Recently I was watching an introduction to TensorFlow and during that course Keras came up as an High Level API that could use either TensorFlow or Theano in the back end.
I played around with both of them and did a MNIST LeNet-5 implementation with first pure TensorFlow and after that with Keras. At least on my Machine I wasn't able to see any significant boost in performance, when using TensorFlow directly.
So my question now is: What are the advantages, of using TensorFlow directly over Keras? Maybe it's a matter of scale, will I see significant boost in perfomance on a larger scale project?
Keras just hides the complexity of Tensorflow (and other backends), that's all.
If you need/want a better control on what's going on under the hood, you could use Tensorflow directly (you can control almost everything and you can be sure that your implementation effectively does what you want).
If you just want to fast prototype and develop your models, then Keras is fine because it allows to do it faster. The trade-off is that you loose a bit of control because Keras does a lot of things for you that you wouldn't. For instance, you can't change the variable name/scope of your convolutional layers because they are fixed within the keras-layer definition (the kernel will always be 'kernel' the bias will always be 'bias').
However, since Tensorflow first builds a graph and then executes it, the execution speed of the same graph defined in Keras or in Tensorflow is the same (Keras slows down only the graph construction, that's just Python code).
Update: from Tensorflow 2.0 the default will be to use tf.keras
: https://pgaleone.eu/tensorflow/gan/2018/11/04/tensorflow-2-models-migration-and-new-design/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With