Tensorflow basic variables const placeholder

Tensorflow basic variables const placeholder

example 1: 


import tensorflow.compat.v1 as tf

#this is a veriable
zero = tf.Variable(0)

#this is a constant
one = tf.constant(1)

new_value = tf.add(zero,one)

#variable value can be chNGED
update= tf.compat.v1.assign(zero,new_value)

#init_op = tf.initialize_all_variables()
init_op = tf.global_variables_initializer()

sess = tf.Session()

#initialize variables
sess.run(init_op)

print(sess.run(zero))




Comments

Popular posts from this blog

TensorFlow Train/test /evaluation flow

AttributeError : module 'tensorflow' has no attribute 'global_variables_initializer'

AttributeError: module 'tensorflow_estimator.python.estimator.api._v2.estimator' has no attribute 'inputs'