{"id":13111,"date":"2021-10-27T23:09:03","date_gmt":"2021-10-28T06:09:03","guid":{"rendered":"https:\/\/www.springboard.com\/?p=13111"},"modified":"2023-09-28T00:09:59","modified_gmt":"2023-09-28T07:09:59","slug":"tensorflow-1-0-vs-tensorflow-2-0","status":"publish","type":"post","link":"https:\/\/www.springboard.com\/blog\/data-science\/tensorflow-1-0-vs-tensorflow-2-0\/","title":{"rendered":"Tensorflow 1.0 vs. Tensorflow 2.0: What&#8217;s the Difference?"},"content":{"rendered":"\n<p>TensorFlow 1.0 vs TensorFlow 2.0 has been the point of focus for data learning enthusiasts across the world ever since Google released TensorFlow 2.0. Google Brain launched TensorFlow 1.0 in 2017, whereas the updated version i.e TensorFlow 2.0\u2019s release date was September 30, 2019. TensorFlow quickly became the most popular open-source ML library. And now with the release of TensorFlow 2.0, even beginners can execute deep learning tasks.  <\/p>\n\n\n\n<p><strong>Here are some TensorFlow facts: <\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>TensorFlow is transforming all genres of industries including pharma, healthcare, banking, or agriculture.<\/li>\n\n\n\n<li>It has played a huge role in enabling companies to leverage artificial intelligence and thereby make their products\/services smarter than ever before. <\/li>\n\n\n\n<li>All the industry giants ranging from CocaCola, Airbnb, Airbus, Dropbox, LinkedIn, PayPal, Twitter, and Uber vouch for this software library. <\/li>\n\n\n\n<li>Image recognition, speech recognition, sentiment analysis, object detection, and video detection are some of its most popular use cases. <\/li>\n<\/ul>\n\n\n\n<p>Such is the utility of TensorFlow! Having worked thoroughly on the drawbacks of TensorFlow 1.0, the team released a better, smarter, and an easier version i.e TensorFlow 2.0. And hence this article will deal with TensorFlow 1.0 vs TensorFlow 2.0 &#8211; and will answer all your related questions. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tensorflow 1.0 vs Tensorflow 2.0: Understanding the Difference<\/h2>\n\n\n\n<p>Let\u2019s begin with the basics by understanding each individually.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>What is TensorFlow? <\/strong><\/h3>\n\n\n\n<p>TensorFlow is an <a href=\"https:\/\/www.springboard.com\/blog\/data-science\/open-source-machine-learning-tools\/\" target=\"_blank\" data-type=\"URL\" data-id=\"https:\/\/www.springboard.com\/blog\/data-science\/open-source-machine-learning-tools\/\" rel=\"noreferrer noopener\">end-to-end open-source<\/a> machine learning platform that contains comprehensive tools, libraries and community resources. It is meant for developers, <a href=\"https:\/\/www.springboard.com\/blog\/data-science\/what-does-a-data-scientist-do\/\" target=\"_blank\" data-type=\"post\" data-id=\"24427\" rel=\"noreferrer noopener\">data scientists<\/a> and researchers to build and deploy applications powered by machine learning.&nbsp;TensorFlow was essentially built to scale, developed by Google Brain team, TensorFlow accelerates ML and deep neural network research. It can run on multiple CPUs or GPUs and mobile operating systems. Also, it has several wrappers in languages like Python, C++, or Java.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>What is TensorFlow 2.0?<\/strong><\/h3>\n\n\n\n<p>TensorFlow 2.0 is an updated version of TensorFlow that has been designed with a focus on simple execution, ease of use, and developer\u2019s productivity.&nbsp;TensorFlow 2.0 makes the development of <a href=\"https:\/\/www.springboard.com\/blog\/data-science\/data-science-definition\/\" target=\"_blank\" data-type=\"URL\" data-id=\"https:\/\/www.springboard.com\/blog\/data-science\/data-science-definition\/\" rel=\"noreferrer noopener\">data science<\/a> and machine learning applications even easier.&nbsp;With updated features like tight integration of Keras, default Eager execution, and Pythonic function execution, there have been considerable and successful efforts to make the experience of developing applications more familiar for Python developers.&nbsp;<\/p>\n\n\n\n<p>The TensorFlow team has also invested heavily in low-level API this time. All the ops that are used internally are now exported and inheritable interfaces for concepts such as variables and checkpoints are provided. So, as you build onto the internals of TensorFlow, you won\u2019t have to rebuild TensorFlow.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>TensorFlow 2.0 Tutorial: Stepwise Installation Guide<\/strong><\/h4>\n\n\n\n<p><strong>Google Colab:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open Google Colab on the link. <a aria-label=\" (opens in a new tab)\" href=\"https:\/\/colab.research.google.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/colab.research.google.com\/<\/a>.<\/li>\n\n\n\n<li>Create a \u2018New Python 3 Notebook\u2019.<\/li>\n\n\n\n<li>Connect to GPU\/CPU.<\/li>\n\n\n\n<li>Check if you\u2019re using 2.0 version. If not, uninstall using !pip uninstall TensorFlow and then install it using !pip install TensorFlow<\/li>\n<\/ol>\n\n\n<div class=\"bg-leaf-50 p-4 my-3\"><h4 class=\"fw-bold text-center\">Get To Know Other\tData Science Students<\/h4><div class=\"row row-cols-1 row-cols-lg-3\"><div class=\"col\"><div class=\"card success-story-card h-100 d-flex justify-content-between mb-0\"><div class=\"flex-grow-1 text-center\"><a class=\"d-inline-block rounded-circle\" href=\"\/success\/isabel-van-zijl\" style=\"width:125px;height:125px;overflow:hidden\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/res.cloudinary.com\/springboard-images\/image\/upload\/v1629203192\/Student%20Success\/Isabel_van_Zijl_125x125.png\" alt=\"Isabel Van Zijl\" style=\"object-fit:contain;max-width:170px;height:125px\" \/><\/a><p class=\"fw-bold mb-0\">Isabel Van Zijl<\/p><p class=\"text-muted lh-1\">Lead Data Analyst at Kinship<\/p><\/div><div class=\"w-100 d-block d-md-none mt-3\"><\/div><p class=\"mb-0 mx-auto text-center\"><a class=\"btn btn-primary mx-auto\" href=\"\/success\/isabel-van-zijl\">Read Story<\/a><\/p><\/div><\/div><div class=\"col d-none d-md-block\"><div class=\"card success-story-card h-100 d-flex justify-content-between mb-0\"><div class=\"flex-grow-1 text-center\"><a class=\"d-inline-block rounded-circle\" href=\"\/success\/pizon-shetu\" style=\"width:125px;height:125px;overflow:hidden\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/res.cloudinary.com\/springboard-images\/image\/upload\/v1651030560\/Student%20Success\/Pizon_Shetu.jpg\" alt=\"Pizon Shetu\" style=\"object-fit:contain;max-width:170px;height:125px\" \/><\/a><p class=\"fw-bold mb-0\">Pizon Shetu<\/p><p class=\"text-muted lh-1\">Data Scientist at Whiterock AI<\/p><\/div><p class=\"mb-0 mx-auto text-center\"><a class=\"btn btn-primary mx-auto\" href=\"\/success\/pizon-shetu\">Read Story<\/a><\/p><\/div><\/div><div class=\"col d-none d-md-block\"><div class=\"card success-story-card h-100 d-flex justify-content-between mb-0\"><div class=\"flex-grow-1 text-center\"><a class=\"d-inline-block rounded-circle\" href=\"\/success\/cassie-gong\" style=\"width:125px;height:125px;overflow:hidden\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/res.cloudinary.com\/springboard-images\/image\/upload\/v1629203193\/Student%20Success\/Cassie_Gong_125x125.png\" alt=\"Mengqin (Cassie) Gong\" style=\"object-fit:contain;max-width:170px;height:125px\" \/><\/a><p class=\"fw-bold mb-0\">Mengqin (Cassie) Gong<\/p><p class=\"text-muted lh-1\">Data Scientist at Whatsapp<\/p><\/div><p class=\"mb-0 mx-auto text-center\"><a class=\"btn btn-primary mx-auto\" href=\"\/success\/cassie-gong\">Read Story<\/a><\/p><\/div><\/div><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>TensorFlow 1.0 vs TensorFlow 2.0: What is the difference?<\/strong><\/h2>\n\n\n\n<p><strong>(As per the TensorFlow team)<\/strong> It is important to understand that there is no battle of TensorFlow 1.0 vs TensorFlow 2.0 as TensorFlow 2.0 is the updated version and hence clearly better and smarter. It was built keeping in mind the drawbacks of TensorFlow 1.0 which was particularly hard to use and understand. <\/p>\n\n\n\n<p><strong>Here\u2019s the story: <\/strong><\/p>\n\n\n\n<p>Beginners and experts used to be disheartened seeing the exhausting TensorFlow code. Why? Because its logic of coding was vastly different from that of other libraries. This led to the popularisation of higher-level packages such as Pytorch and Keras. Both Keras and TensorFlow are open-source and in 2017, Keras was integrated into TensorFlow. However, even after this integration, TensorFlow was still losing popularity. This was until 2019 when TensorFlow 2.0 came into the picture. Through TensorFlow 2.0, the team aimed to catch up with the higher-level programming demand. But instead of creating their high-level syntax, the developers went on to borrow that of Keras. So, now the TensorFlow 2.0 has the versatility of Tensorflow 1.0 and the simplicity of Keras. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Major Changes in the two Libraries<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Keras as the high-level API<\/strong>: As mentioned earlier, Google has incorporated Keras as a high-level API in TensorFlow 2.0 to build and train ML models. This will make it easy for users to get started with TensorFlow. <\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Compatible TensorFlow ecosystem<\/strong>: In TensorFlow 2.0, as soon as the training for a model is completed, it can be deployed in production on other platforms. TensorFlow Lite, TensorFlow.js, and TensorFlow Extended are the deployment libraries available for users.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>TensorFlow.js &#8211; JavaScript library to train and deploy models in the browser and on Node.js.<\/li>\n\n\n\n<li>TensorFlow Lite &#8211; Lightweight library to deploy models on mobile and embedded devices.<\/li>\n\n\n\n<li>TensorFlow Extended &#8211; An end-to-end platform to prepare data, train, validate, and deploy models in large production environments.<\/li>\n<\/ol>\n\n\n\n<p>Also, there is a conversion tool provided to simplify migration from TensorFlow 1.0 to TensorFlow 2.0. This tool will be used to update the Python code to use compatible APIs where possible. It will also highlight the areas where your code cannot be automatically converted. <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>API Cleanup<\/strong>: In TensorFlow 2.0, APIs have either gone or moved. Some of them have also been replaced with their 2.0 equivalents that are <strong>tf.summary, tf.keras.metrics, and tf.keras.optimizers<\/strong>. To automatically apply these renames, you need to use the v2 upgrade script.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Default Eager execution:<\/strong> In TensorFlow 1.0, the operation is performed inside a session. A session is an environment wherein the objects are executed. So, if you had to add two constants, TensorFlow 1.0 wouldn\u2019t give you the results until you performed it inside a session. But with TensorFlow 2.0, you can do it directly. That\u2019s Eager Execution. <\/li>\n<\/ul>\n\n\n\n<p>TensorFlow 1.0 code <\/p>\n\n\n\n<p>a = tf.constant(5)<br>b = tf.constant(4)<br>c = a + b<br>with tf.Session() as sess:<br>print(sess.run(c))<\/p>\n\n\n\n<p>Simplified TensorFlow 2.0 code because of Eager Execution: <\/p>\n\n\n\n<p>a = tf.constant(5)<br>b = tf.constant(4)<br>c = a + b<br><strong>print<\/strong>(c)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>No more globals: <\/strong>TensorFlow relied on implicitly global namespaces. So, what happened is &#8211; if you called tf.variable(), it would be put into the default graph. And even if you lose the Python variable pointing to it, it would remain there nonetheless. You could only recover that tf.variable if you knew the name it was created with. Now, since the user doesn\u2019t control the creation of the variable, it was extremely difficult to recover it. In TensorFlow 2.0, developers have taken care of this issue. If you lose track of tf.variable in TensorFlow 2.0, it will be garbage collected. <\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Functions, not sessions: <\/strong>A session.run() call is very similar to a function call: Users state the inputs and the function to be called and get the outputs. In TensorFlow 2.0, however, users can decorate a Python function by using tf.function(). This will mark it for JIT compilation and TensorFlow will run it as a single graph. Through this, TensorFlow 2.0 can leverage the performance and portability of the graph mode completely as the function can be optimised (node pruning, kernel fusion, etc.) and exported\/reimported.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Ease for researchers: <\/strong>TensorFlow 2.0 is for all &#8211; beginners and researchers. It is however great for advanced-level users. The extensions such as Ragged Tensors, TensorFlow Probability, and Tensor2Tensor will be especially useful. TensorFlow 2.0 comes with default Eager execution which will deliver clear messages and aid researchers to debug any issue. Also, researchers will be able to jump to the source of the error in the original code.<\/li>\n<\/ul>\n\n\n\n<p>Now that you here and have a fair idea of TensorFlow and TensorFlow 1.0 vs TensorFlow 2.0, I am assuming you\u2019re one of our deep learning enthusiasts.&nbsp;And if this interests you, I have a whole world of deep learning for you to get your basics on point. Springboard\u2019s courses on <a href=\"https:\/\/www.springboard.com\/courses\/data-science-career-track\/\" target=\"_blank\" rel=\"noreferrer noopener\">data science<\/a>,&nbsp;<a href=\"https:\/\/www.springboard.com\/courses\/data-analytics-career-track\/\" target=\"_blank\" rel=\"noreferrer noopener\">data analytics<\/a>, and&nbsp;<a href=\"https:\/\/www.springboard.com\/courses\/ai-machine-learning-career-track\/\" target=\"_blank\" rel=\"noreferrer noopener\">Artificial Intelligence\/Machine Learning<\/a>&nbsp;are 1:1 mentoring-led and project-based. The best part is they are industry focussed and job-oriented especially designed for technology enthusiasts, like you, to serve you with a career that matters.&nbsp;<\/p>\n\n\n\n<p class=\"rm has-background\" style=\"background-color:#efeff6\"><strong>Since you\u2019re here\u2026<br><\/strong>Curious about a career in data science? Experiment with our <a rel=\"noreferrer noopener\" href=\"https:\/\/www.springboard.com\/resources\/guides\/data-science-process\/\" target=\"_blank\">free data science learning path<\/a>, or join our <a rel=\"noreferrer noopener\" href=\"https:\/\/www.springboard.com\/courses\/data-science-career-track\/\" target=\"_blank\">Data Science Bootcamp<\/a>, where you\u2019ll get your tuition back if you don&#8217;t land a job after graduating. We\u2019re confident because our courses work \u2013 check out our <a rel=\"noreferrer noopener\" href=\"https:\/\/www.springboard.com\/success\/\" target=\"_blank\">student success stories<\/a> to get inspired.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TensorFlow 1.0 vs TensorFlow 2.0 has been the point of focus for data learning enthusiasts across the world ever since Google released TensorFlow 2.0. Google Brain launched TensorFlow 1.0 in 2017, whereas the updated version i.e TensorFlow 2.0\u2019s release date was September 30, 2019. TensorFlow quickly became the most popular open-source ML library. And now [&hellip;]<\/p>\n","protected":false},"author":100,"featured_media":10294,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_eb_attr":"","_eb_data_table":"","footnotes":""},"categories":[67],"tags":[],"marketing_tags":[1466],"class_list":{"0":"post-13111","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-science"},"acf":[],"_links":{"self":[{"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/posts\/13111"}],"collection":[{"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/comments?post=13111"}],"version-history":[{"count":4,"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/posts\/13111\/revisions"}],"predecessor-version":[{"id":50106,"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/posts\/13111\/revisions\/50106"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/media\/10294"}],"wp:attachment":[{"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/media?parent=13111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/categories?post=13111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/tags?post=13111"},{"taxonomy":"marketing_tags","embeddable":true,"href":"https:\/\/www.springboard.com\/blog\/wp-json\/wp\/v2\/marketing_tags?post=13111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}