#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!')
#类比 数组 M行N列 [] 内部[] [里面 列数据] [] 中括号整体 行数 #[[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]))# 打印某一行 print(sess.run(data4[:,0]))#MN 列 print(sess.run(data4[0,0]))# 1 1 print(sess.run(data4[0,1]))# 1 2 MN = 0 32 = M012 N01