python element in list and element no in list, simple example
element in list
if 2 in [1, 2, 3]:
print('2 in list')
else:
print('2 in not list')
if 4 in [1, 2, 3]:
print('4 in list')
else:
print('4 in not list')
if (1,2) in [(1, 2) , (3, 2)]:
print('(1,2) in list')
else:
print('(1,2) in not list')
result

element no in list
if 4 not in [1, 2, 3]:
print('4 not in list')
else:
print('4 in list')
if (1,2) not in [(1, 2), (3, 2)]:
print('(1,2) in not linst')
else:
print('(1,2) in list')
result

Labels:
element exist
in list
list
not in list
Python
Total
TensorFlow Basic, print tf.Variable, ^^
All things start from the session
import tensorflow as tf
#define a variable to hold normal random values
normal_rv = tf.Variable( tf.truncated_normal([10,10],stddev = 0.1))
#initialize the variable
init_op = tf.initialize_all_variables()
#run the graph
with tf.Session() as sess:
sess.run(init_op) #execute init_op
#print the random values that we sample
print (sess.run(normal_rv)
#define a variable to hold normal random values
normal_rv = tf.Variable( tf.truncated_normal([10,10],stddev = 0.1))
#initialize the variable
init_op = tf.initialize_all_variables()
#run the graph
with tf.Session() as sess:
sess.run(init_op) #execute init_op
#print the random values that we sample
print (sess.run(normal_rv)
or
import tensorflow as tf
def create_weights(shape):
return tf.Variable(tf.truncated_normal(shape, stddev=0.1))
weights = create_weights(shape=[10,10])
init_op = tf.initialize_all_variables()
#run the graph
with tf.Session() as sess:
sess.run(init_op) #execute init_op
#print the random values that we sample
weights = create_weights(shape=[10,10])
init_op = tf.initialize_all_variables()
#run the graph
with tf.Session() as sess:
sess.run(init_op) #execute init_op
#print the random values that we sample
print (sess.run(weights))
reference : https://stackoverflow.com/questions/33633370/how-to-print-the-value-of-a-tensor-object-in-tensorflow
Labels:
Deep learning
tensor flow
tf.variable
Total
Subscribe to:
Posts (Atom)