Skip to content
Advertisement

Convert Tensorflow 1.0 code into 2.0 version

I am facing issue while converting my tensorflow 1.0 code into 2.0

I can convert successful this

version 1

JavaScript

Version 2

JavaScript

This is the code below which i am having issue please help me out how can i build NN in tensorflow 2 version

JavaScript

Advertisement

Answer

I could not understand your question properly (i.e what is version 1 and version 2 and what do you want to convert from tf 1.0 to tf 2.0) but to convert any code from tensorflow version 1.0 to 2.0 is very easy.

While importing tensorflow instead of doing import tensorflow as tf do import tensorflow.compat.v1 as tf and if you want to import a specific module from tensorflow(e.g from tensorflow.keras.models import Model) do from tensorflow.compat.v1.keras.models import Model.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement