title: Sampling in tensorflow
body: <p>I am sampling points in each image using the following function. tf.range gives an error if batch_size is None. How do I sample in tensorflow </p>
  
  <pre><code>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)
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>_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: ?
  </code></pre>
  
  <p>During the test and training time I will have batch_size an integer but when I initialize I want to give None as input so that batch size can be varied during test and training time.</p>