Q:TypeError: Expected int32, got list containing Tensors of type '_Message' instead.
A:
tensorflow tf.concat的版本问题
net = tf.concat(3, [branch_0, branch_1, branch_2, branch_3])
should be changed to
net = tf.concat([branch_0, branch_1, branch_2, branch_3], 3)
将坐标的位置从前换到后
新建一个与给定的tensor类型大小一致的tensor,其所有元素为1和0
tf.ones_like(tensor,dype=None,name=None)
tf.zeros_like(tensor,dype=None,name=None)
python 中None算是False
continue and break只在for循环里用
出处:https://blog.csdn.net/william_hehe/article/details/81612640
1.函数功能:
插入一个张量的占位符,这个张量总是被喂入图片数据。相当于一个形参。
形参:只有在被调用时才分配内存单元,在调用结束时,就会释放出所分配的内存单元。
2.函数参数:
dtype:数据类型;shape:数据维度;name:数据名称
3.代码实现:
import tensorflow as tf
input1 = tf.placeholder(tf.float32,[1,2],name="a")
input2 = tf.placeholder(tf.float32,[2,1],name="b")
output1 = tf.multiply(input1,input2) #两个矩阵中对应元素各自相乘
output2 = tf.matmul(input1,input2) #将矩阵a乘以矩阵b,生成a * b。
with tf.Session() as sess:
print(sess.run(output1,feed_dict={input1:[[1.,2.]],input2:[[3.],[4.]]}))
print(sess.run(output2, feed_dict={input1: [[1., 2.]], input2: [[3.], [4.]]}))
``
将shape为None的tensor和正常tensor concat
The most general solution is to use the tf.shape() op to get the run-time size of the placeholder, and the tf.tile() op to expand h to the appropriate size:
ph_input = tf.placeholder(dtype=tf.int32, shape=[None, 1])
h = tf.zeros([1, 2], dtype=tf.int32) # …or some other tensor of shape [1, 2]
Get the number of rows in the fed value at run-time.
ph_num_rows = tf.shape(ph_input)[0]
Makes a ph_num_rows x 2
matrix, by tiling h
along the row dimension.
h_tiled = tf.tile(h, tf.pack([ph_num_rows, 1]))
result = tf.concat(1, [ph_input, h_tiled])
引用:https://wiki.jikexueyuan.com/project/tensorflow-zh/how_tos/threading_and_queues.html