#placehold
import tensorflow as tf
data1 = tf.placeholder(tf.float32)
data2 = tf.placeholder(tf.float32)
dataAdd = tf.add(data1,data2)
with tf.Session() as sess:
print(sess.run(dataAdd,feed_dict={data1:6,data2:2}))
# 1 dataAdd 2 data (feed_dict = {1:6,2:2})
print('end!')
8.0
end!
#類比 數(shù)組 M行N列 [] 內(nèi)部[] [里面 列數(shù)據(jù)] [] 中括號(hào)整體 行數(shù)
#[[6,6]] [[6,6]]
import tensorflow as tf
data1 = tf.constant([[6,6]]) #一行兩列
data2 = tf.constant([[2], #兩行一列
[2]])
data3 = tf.constant([[3,3]])
data4 = tf.constant([[1,2],
[3,4],
[5,6]])
print(data4.shape)# 維度
with tf.Session() as sess:
print(sess.run(data4)) #打印整體
print(sess.run(data4[0]))# 打印某一行惰蜜,此處第1行
print(sess.run(data4[:,0]))# 打印某列
print(sess.run(data4[0,1]))
(3, 2)
[[1 2]
[3 4]
[5 6]]
[1 2]
[1 3 5]
2