Thomas
Thomas

Reputation: 331

calling tensorflow from keras.backend

I am learning Keras and Thensorflow for deep learning and I have a question.

With this imports:

 import tensorflow as tf
 from keras import backend as K

Is there a difference between these two calls:

K.foo

and

tf.foo

?

In which conditions are they equivalent ?

Upvotes: 2

Views: 581

Answers (1)

Daniel Möller
Daniel Möller

Reputation: 86600

Yes, there may be a difference.

Keras is built on top of a backend. This backend may be Tensorflow, Theano or CNTK.

So, a function from keras will call a function from the backend, something like this:

#at keras.backend 
def foo(args**):

    #there may be some preprocessing or inversion in dimensions
    return tf.foo(args_that_may_be_different**)

It's impossible to have an answer for all functions. Some are indeed exactly the same, some may have a difference.

You can search the backend codes, speficially the tensorflow backend and see how keras handles each function.

Upvotes: 2

Related Questions