<jupyter_start><jupyter_text>The difference is that with tf.Variable you have to provide an initial value when you declare it. With tf.placeholder you don't have to provide an initial value and you can specify it at run time with the feed_dict argument inside Session.run<jupyter_code>import numpy as np
x = tf.placeholder(tf.float32,shape=(4,4))
y = tf.matmul(x,x)
with tf.Session() as sess:
    rand_arr = np.random.rand(4,4)
    print(sess.run(y,feed_dict={x:rand_arr}))
b = tf.placeholder(tf.float32,[None,1], name='b')
x = np.array([[[1],[2],[3]], [[4],[5],[6]]])
x.shape
x
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)

adder_node = a+b
sess = tf.Session()

print(sess.run(adder_node,{a:[1,3],b:[2,4]}))
import tensorflow as tf
#Model parameters
W = tf.Variable([.3],tf.float32)
b = tf.Variable([-.3], tf.float32)

#Inputs and Outputs
x = tf.placeholder(tf.float32)
y = tf.placeholder(tf.float32)  # Actual output which we already know

linear_model = W*x+b

#Loss ffunction
squared_delta = tf.square(linear_model - y)
loss = tf.reduce_sum(squared_delta)

##optimize
optimizer = tf.train.GradientDescentOptimizer(0.01)
train = optimizer.minimize(loss)


init = tf.global_variables_initializer()

sess = tf.Session()
sess.run(init)
#print(sess.run(loss,{x:[1,2,3,4],y:[0,-1,-2,-3]}))
for i in range(1000):
    sess.run(train,{x:[1,2,3,4],y:[0,-1,-2,-3]})
    
print(sess.run([W,b]))<jupyter_output>[array([-0.9999969], dtype=float32), array([ 0.99999082], dtype=float32)]
{'fraction_non_alphanumeric': 0.17828418230563003, 'fraction_numerical': 0.05160857908847185, 'mean_word_length': 5.5196506550218345, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '362792', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 630, 'n_tokens_neox': 578, 'n_words': 126, 'path': 'DeepNetwork/tensolflowTest1.ipynb', 'repo_name': 'prashantas/MyOwnR', 'size': '1492'}