I am facing issue while converting my tensorflow 1.0 code into 2.0
I can convert successful this
version 1
# reset underlying graph data #tf.reset_default_graph()
Version 2
from tensorflow.python.framework import ops ops.reset_default_graph()
This is the code below which i am having issue please help me out how can i build NN in tensorflow 2 version
# Build neural network net = tflearn.input_data(shape=[None, len(train_x[0])]) net = tflearn.fully_connected(net, 8) net = tflearn.fully_connected(net, 8) net = tflearn.fully_connected(net, len(train_y[0]), activation='softmax') net = tflearn.regression(net) # Define model and setup tensorboard model = tflearn.DNN(net, tensorboard_dir='tflearn_logs') # Start training (apply gradient descent algorithm) model.fit(train_x, train_y, n_epoch=100, batch_size=8, show_metric=True) model.save('my_drive/AI_values/model/model.ckpt')
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
.