我是每个图像的采样点使用以下功能。如果tf.range为None,则batch_size将出现错误。如何在tensorflow中取样?
def sampling(binary_selection,num_points, points):
"""
binary_selection: tensor of size (batch_size, points)
with values 1.0 or 0.0. Indicating positive and negative points.
We want to sample num_points from positive points of each image
points: tensor of size (batch_size, num_points_in_image)
num_points: number of points to sample for each image
"""
batch_size = points.get_shape()[0]
indices = tf.multinomial((tf.log(binary_selection)), num_points)
indices = tf.cast(tf.expand_dims(indices, axis=2), tf.int32)
batch_seq = tf.expand_dims(tf.range(batch_size), axis=1)
im_indices = tf.expand_dims(tf.tile(batch_seq, [1, num_points]), axis=2)
indices = tf.concat([im_indices, indices], axis=2)
return tf.gather_nd(points, indices)我得到以下错误
_dimension_tensor_conversion_function raise ValueError("Cannot convert an unknown Dimension to a Tensor: %s" % d) ValueError: Cannot convert an unknown Dimension to a Tensor: ?在测试和培训期间,我将拥有一个整数的batch_size,但是当我初始化时,我希望没有一个作为输入,这样就可以在测试和培训期间改变批处理大小。
发布于 2018-06-18 01:48:53
您需要向batch_size提供一个值。
它需要初始化。
目前,它没有任何价值。
https://stackoverflow.com/questions/50901790
复制相似问题