tensorflow学习笔记——传入值之placeholder,feed_dict用法
tensorflow学习笔记——传入值之placeholder,feed_dict用法
描述
tensorflow中需要传入值时,要同时用到placeholder、feed_dict。 - placeholder定义输入值的类型,以及数据结构 - feed_dict,表示python中的字典(python中dist是字典,元素是键值对的存储模式),用于接收真实的输入值。
相关公式
矩阵乘法中的两个矩阵,以及输出结果为: [102131]×⎡⎣⎢310221⎤⎦⎥=[5193] [123011]×[321201]=[5913] 源代码
#coding:UTF-8 import tensorflow as tf
#输入 input1 = tf.placeholder(tf.float32,(2,3))#placeholder(dtype,shape),定义一个3行2列的矩阵 input2 = tf.placeholder(tf.float32,(3,2))#定义一个2行3列的矩阵
#输出 output = tf.matmul(input1,input2)#matmul(),矩阵乘法
#执行 with tf.Session() as sess: result = sess.run(output,feed_dict = {input1:[[1,2,3],[0,1,1]],input2:[[3,2],[1,2],[0,1]]}) print result --------------------- 作者:Manduner_TJU 来源:CSDN 原文:https://blog.csdn.net/manduner/article/details/80679049 版权声明:本文为博主原创文章,转载请附上博文链接!

浙公网安备 33010602011771号