首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >抽样调查

抽样调查
EN

Stack Overflow用户
提问于 2018-06-18 01:43:12
回答 1查看 753关注 0票数 1

我是每个图像的采样点使用以下功能。如果tf.range为None,则batch_size将出现错误。如何在tensorflow中取样?

代码语言:javascript
复制
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)

我得到以下错误

代码语言:javascript
复制
_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,但是当我初始化时,我希望没有一个作为输入,这样就可以在测试和培训期间改变批处理大小。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-18 01:48:53

您需要向batch_size提供一个值。

它需要初始化。

目前,它没有任何价值。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50901790

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档