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
#1
Hello,

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!
bytecrunch
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  1st layer tf.keras output shape set at multiple - need help! Afrodizzyjack 0 1,786 Jun-07-2022, 04:53 PM
Last Post: Afrodizzyjack
  issue displaying summary of whole keras CNN model on TensorFlow with python Afrodizzyjack 0 1,619 Oct-27-2021, 04:07 PM
Last Post: Afrodizzyjack
  Problems feeding live input from my microphone into a keras model (SegFault: 11) zeptozetta 1 2,543 Sep-14-2020, 03:08 AM
Last Post: zeptozetta
  Keras.Predict into Dataframe Finpyth 13 9,587 Aug-31-2020, 07:22 AM
Last Post: hussainmujtaba
  Making a Basic Keras Model - Input Shape and Parameters MattKahn13 0 2,094 Aug-16-2020, 04:36 PM
Last Post: MattKahn13
  Error when import Keras Azadfalah 1 2,754 Apr-29-2020, 04:45 AM
Last Post: buran
  Keras + Matplotlib causing crash spearced 3 4,442 Feb-06-2020, 04:54 PM
Last Post: zljt3216
  Keras Dense layer with wrong input d1r4c 0 1,740 Jan-02-2020, 02:35 PM
Last Post: d1r4c
  Keras: Time series classification midarq 0 1,965 Sep-25-2019, 09:03 AM
Last Post: midarq
  Keras. ModuleNotFoundError: No module named 'error' agatte 1 7,061 Sep-18-2019, 12:27 PM
Last Post: shivani

Forum Jump:

User Panel Messages

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