Python Forum
Understanding Keras and TensorFlow and how to use them
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding Keras and TensorFlow and how to use them

I am new to deep learning but realize that Keras and TensorFlow are two very important DL libraries.

My understanding is that Keras is an API, a wrapper, and the front-end of TensorFlow. Do API and wrapper mean exactly the same thing?
Keras is a library containing functions that can be called to let us indirectly use the functionalities of TF more easily. Is that correct?

I believe TensorFlow can be used without using Keras but Keras must always be used with TensorFlow, correct? Both an API and a wrapper are an interface to something else...
I have seen Python script examples where only Keras was imported and TensorFlow wasn't. Is it because the newest version of TensorFlow (TensorFlow 2) is automatically imported when we import Keras alone?

Online, I noticed that different approaches. Some code imports tensorflow, some just keras. What is the correct syntax and way to use Keras and TF? Here the options I found:

1) Only tensorflow is imported:
import tensorflow as tfmodel = tf.keras.Sequential()

2) Here Keras is imported as an object inside tensorflow:
from tensorflow import keras
model = keras.Sequential()

3)Here there is no mention of TF and only Keras is imported:
import keras
from keras.models import Sequential

Which one is the correct approach?
Thank you!
It depends.
Some of the complexity is that Keras was designed to be a front end that could use multiple back ends. As of version 2.4 it only supports Tensorflow. So, depending on the age of the lesson or video it may even talk about Keras with Theano or the Microsoft Cognitive Toolkit.

Recommend Keras's about page at HERE to give you a little bit of overview of what Keras is and why.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Keras.Predict into Dataframe Finpyth 13 2,938 Aug-31-2020, 07:22 AM
Last Post: hussainmujtaba
  Making a Basic Keras Model - Input Shape and Parameters MattKahn13 0 786 Aug-16-2020, 04:36 PM
Last Post: MattKahn13
  Error when import Keras Azadfalah 1 858 Apr-29-2020, 04:45 AM
Last Post: buran
  Keras + Matplotlib causing crash spearced 3 1,857 Feb-06-2020, 04:54 PM
Last Post: zljt3216
  Keras Dense layer with wrong input d1r4c 0 655 Jan-02-2020, 02:35 PM
Last Post: d1r4c
  Keras: Time series classification midarq 0 943 Sep-25-2019, 09:03 AM
Last Post: midarq
  Keras. ModuleNotFoundError: No module named 'error' agatte 1 4,271 Sep-18-2019, 12:27 PM
Last Post: shivani
  Keras Target Problem inco 1 1,593 May-05-2019, 10:47 AM
Last Post: scidam
  keras tensor mainpulation output to next input JohnyBeGood 0 1,022 Nov-21-2018, 03:30 PM
Last Post: JohnyBeGood
  Keras: tweets classicifcation kiton 0 1,301 Nov-14-2018, 03:19 PM
Last Post: kiton

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020