當前位置: 首頁>>代碼示例>>Python>>正文


Python tf_grouping.query_ball_point方法代碼示例

本文整理匯總了Python中tf_grouping.query_ball_point方法的典型用法代碼示例。如果您正苦於以下問題:Python tf_grouping.query_ball_point方法的具體用法?Python tf_grouping.query_ball_point怎麽用?Python tf_grouping.query_ball_point使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tf_grouping的用法示例。


在下文中一共展示了tf_grouping.query_ball_point方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_grad

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def test_grad(self):
    with tf.device('/gpu:0'):
      points = tf.constant(np.random.random((1,128,16)).astype('float32'))
      print points
      xyz1 = tf.constant(np.random.random((1,128,3)).astype('float32'))
      xyz2 = tf.constant(np.random.random((1,8,3)).astype('float32'))
      radius = 0.3 
      nsample = 32
      idx, pts_cnt = query_ball_point(radius, nsample, xyz1, xyz2)
      grouped_points = group_point(points, idx)
      print grouped_points

    with self.test_session():
      print "---- Going to compute gradient error"
      err = tf.test.compute_gradient_error(points, (1,128,16), grouped_points, (1,8,32,16))
      print err
      self.assertLess(err, 1e-4) 
開發者ID:mhsung,項目名稱:deep-functional-dictionaries,代碼行數:19,代碼來源:tf_grouping_op_test.py

示例2: test_grad

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def test_grad(self):
    with tf.device('/gpu:0'):
      points = tf.constant(np.random.random((1,128,16)).astype('float32'))
      print(points)
      xyz1 = tf.constant(np.random.random((1,128,3)).astype('float32'))
      xyz2 = tf.constant(np.random.random((1,8,3)).astype('float32'))
      radius = 0.3
      nsample = 32
      idx, pts_cnt = query_ball_point(radius, nsample, xyz1, xyz2)
      grouped_points = group_point(points, idx)
      print(grouped_points)

    with self.test_session():
      print("---- Going to compute gradient error")
      err = tf.test.compute_gradient_error(points, (1,128,16), grouped_points, (1,8,32,16))
      print(err)
      self.assertLess(err, 1e-4) 
開發者ID:xingyul,項目名稱:meteornet,代碼行數:19,代碼來源:tf_grouping_op_test.py

示例3: test_grad

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def test_grad(self):
    with tf.device('/gpu:0'):
      points = tf.constant(np.random.random((1,128,16)).astype('float32'))
      print(points)
      xyz1 = tf.constant(np.random.random((1,128,3)).astype('float32'))
      xyz2 = tf.constant(np.random.random((1,8,3)).astype('float32'))
      radius = 0.3 
      nsample = 32
      idx, pts_cnt = query_ball_point(radius, nsample, xyz1, xyz2)
      grouped_points = group_point(points, idx)
      print(grouped_points)

    with self.test_session():
      print("---- Going to compute gradient error")
      err = tf.test.compute_gradient_error(points, (1,128,16), grouped_points, (1,8,32,16))
      print(err)
      self.assertLess(err, 1e-4) 
開發者ID:voidrank,項目名稱:Geo-CNN,代碼行數:19,代碼來源:tf_grouping_op_test.py

示例4: test_grad

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def test_grad(self):
    with tf.device('/gpu:1'):
      points = tf.constant(np.random.random((4,256,8)).astype('float32'))
      print (points)
      xyz1 = tf.constant(np.random.random((4,256,3)).astype('float32'))
      xyz2 = tf.constant(np.random.random((4,256,3)).astype('float32'))
      radius = 0.3 
      nsample = 256
      idx, pts_cnt = query_ball_point(radius, nsample, xyz1, xyz2)
      grouped_points = group_point(points, idx)
      #grouped_points, max_idx = group_maxpool(points, idx)
      print (grouped_points)

    with self.test_session():
      print ("---- Going to compute gradient error")
      err = tf.test.compute_gradient_error(points, (4,256,8), grouped_points, (4,256,256,8))
      #err = tf.test.compute_gradient_error(points, (1,8,4), grouped_points, (1,2,4))
      print (err)
      self.assertLess(err, 1e-4) 
開發者ID:ericyi,項目名稱:GSPN,代碼行數:21,代碼來源:tf_grouping_op_test.py

示例5: test_grad

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def test_grad(self):
        with tf.device('/gpu:0'):
            points = tf.constant(np.random.random((1, 128, 16)).astype('float32'))
            print(points)
            xyz1 = tf.constant(np.random.random((1, 128, 3)).astype('float32'))
            xyz2 = tf.constant(np.random.random((1, 8, 3)).astype('float32'))
            radius = 0.3
            nsample = 32
            idx, pts_cnt = query_ball_point(radius, nsample, xyz1, xyz2)
            grouped_points = group_point(points, idx)
            print(grouped_points)

        with self.test_session():
            print("---- Going to compute gradient error")
            err = tf.test.compute_gradient_error(points, (1, 128, 16), grouped_points, (1, 8, 32, 16))
            print(err)
            self.assertLess(err, 1e-4) 
開發者ID:dlinzhao,項目名稱:JSNet,代碼行數:19,代碼來源:tf_grouping_op_test.py

示例6: test_grad

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def test_grad(self):
      with tf.device('/gpu:0'):
          points = tf.constant(np.random.random((1,128,16)).astype('float32'))
          print(points)
          xyz1 = tf.constant(np.random.random((1,128,3)).astype('float32'))
          xyz2 = tf.constant(np.random.random((1,8,3)).astype('float32'))
          radius = 0.3
          nsample = 32
          idx, pts_cnt = query_ball_point(radius, nsample, xyz1, xyz2)
          grouped_points = group_point(points, idx)
          print(grouped_points)

          # with self.test_session():
          with tf.Session() as sess:
              print("---- Going to compute gradient error")
              err = tf.test.compute_gradient_error(points, (1,128,16), grouped_points, (1,8,32,16))
              print(err)
              self.assertLess(err, 1e-4) 
開發者ID:yewzijian,項目名稱:3DFeatNet,代碼行數:20,代碼來源:tf_grouping_op_test.py

示例7: test_grad

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def test_grad(self):
    with tf.device('/gpu:3'):
      points = tf.constant(np.random.random((1,128,16)).astype('float32'))
      print(points)
      xyz1 = tf.constant(np.random.random((1,128,3)).astype('float32'))
      xyz2 = tf.constant(np.random.random((1,8,3)).astype('float32'))
      radius = 0.3 
      nsample = 32
      idx, pts_cnt = query_ball_point(radius, nsample, xyz1, xyz2)
      grouped_points = group_point(points, idx)
      grouped_xyz = group_point(xyz1, idx)
      print grouped_points
      #sess = tf.Session()
      #xyz1_eval, xyz2_eval, grouped_xyz_eval = sess.run([xyz1,xyz2,grouped_xyz])
      #print(xyz1_eval, xyz2_eval, grouped_xyz_eval)

    with self.test_session():
      print "---- Going to compute gradient error"
      err = tf.test.compute_gradient_error(points, (1,128,16), grouped_points, (1,8,32,16))
      print err
      self.assertLess(err, 1e-4) 
開發者ID:ericyi,項目名稱:articulated-part-induction,代碼行數:23,代碼來源:tf_grouping_op_test.py

示例8: sample_and_group

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def sample_and_group(npoint, radius, nsample, xyz, points, knn=False, use_xyz=True):
    '''
    Input:
        npoint: int32
        radius: float32
        nsample: int32
        xyz: (batch_size, ndataset, 3) TF tensor
        points: (batch_size, ndataset, channel) TF tensor, if None will just use xyz as points
        knn: bool, if True use kNN instead of radius search
        use_xyz: bool, if True concat XYZ with local point features, otherwise just use point features
    Output:
        new_xyz: (batch_size, npoint, 3) TF tensor
        new_points: (batch_size, npoint, nsample, 3+channel) TF tensor
        idx: (batch_size, npoint, nsample) TF tensor, indices of local points as in ndataset points
        grouped_xyz: (batch_size, npoint, nsample, 3) TF tensor, normalized point XYZs
            (subtracted by seed point XYZ) in local regions
    '''

    new_xyz = gather_point(xyz, farthest_point_sample(npoint, xyz)) # (batch_size, npoint, 3)
    if knn:
        _,idx = knn_point(nsample, xyz, new_xyz)
    else:
        idx, pts_cnt = query_ball_point(radius, nsample, xyz, new_xyz)
    grouped_xyz = group_point(xyz, idx) # (batch_size, npoint, nsample, 3)
    grouped_xyz -= tf.tile(tf.expand_dims(new_xyz, 2), [1,1,nsample,1]) # translation normalization
    if points is not None:
        grouped_points = group_point(points, idx) # (batch_size, npoint, nsample, channel)
        if use_xyz:
            new_points = tf.concat([grouped_xyz, grouped_points], axis=-1) # (batch_size, npoint, nample, 3+channel)
        else:
            new_points = grouped_points
    else:
        new_points = grouped_xyz

    return new_xyz, new_points, idx, grouped_xyz 
開發者ID:mhsung,項目名稱:deep-functional-dictionaries,代碼行數:37,代碼來源:pointnet_util.py

示例9: pointnet_sa_module_msg

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def pointnet_sa_module_msg(xyz, points, npoint, radius_list, nsample_list, mlp_list, is_training, bn_decay, scope, bn=True, use_xyz=True, use_nchw=False):
    ''' PointNet Set Abstraction (SA) module with Multi-Scale Grouping (MSG)
        Input:
            xyz: (batch_size, ndataset, 3) TF tensor
            points: (batch_size, ndataset, channel) TF tensor
            npoint: int32 -- #points sampled in farthest point sampling
            radius: list of float32 -- search radius in local region
            nsample: list of int32 -- how many points in each local region
            mlp: list of list of int32 -- output size for MLP on each point
            use_xyz: bool, if True concat XYZ with local point features, otherwise just use point features
            use_nchw: bool, if True, use NCHW data format for conv2d, which is usually faster than NHWC format
        Return:
            new_xyz: (batch_size, npoint, 3) TF tensor
            new_points: (batch_size, npoint, \sum_k{mlp[k][-1]}) TF tensor
    '''
    data_format = 'NCHW' if use_nchw else 'NHWC'
    with tf.variable_scope(scope) as sc:
        new_xyz = gather_point(xyz, farthest_point_sample(npoint, xyz))
        new_points_list = []
        for i in range(len(radius_list)):
            radius = radius_list[i]
            nsample = nsample_list[i]
            idx, pts_cnt = query_ball_point(radius, nsample, xyz, new_xyz)
            grouped_xyz = group_point(xyz, idx)
            grouped_xyz -= tf.tile(tf.expand_dims(new_xyz, 2), [1,1,nsample,1])
            if points is not None:
                grouped_points = group_point(points, idx)
                if use_xyz:
                    grouped_points = tf.concat([grouped_points, grouped_xyz], axis=-1)
            else:
                grouped_points = grouped_xyz
            if use_nchw: grouped_points = tf.transpose(grouped_points, [0,3,1,2])
            for j,num_out_channel in enumerate(mlp_list[i]):
                grouped_points = tf_util.conv2d(grouped_points, num_out_channel, [1,1],
                                                padding='VALID', stride=[1,1], bn=bn, is_training=is_training,
                                                scope='conv%d_%d'%(i,j), bn_decay=bn_decay)
            if use_nchw: grouped_points = tf.transpose(grouped_points, [0,2,3,1])
            new_points = tf.reduce_max(grouped_points, axis=[2])
            new_points_list.append(new_points)
        new_points_concat = tf.concat(new_points_list, axis=-1)
        return new_xyz, new_points_concat 
開發者ID:mhsung,項目名稱:deep-functional-dictionaries,代碼行數:43,代碼來源:pointnet_util.py

示例10: sample_and_group

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def sample_and_group(npoint, radius, nsample, xyz, points, knn=False, use_xyz=True):
    '''
    Input:
        npoint: int32
        radius: float32
        nsample: int32
        xyz: (batch_size, ndataset, 3) TF tensor
        points: (batch_size, ndataset, channel) TF tensor, if None will just use xyz as points
        knn: bool, if True use kNN instead of radius search
        use_xyz: bool, if True concat XYZ with local point features, otherwise just use point features
    Output:
        new_xyz: (batch_size, npoint, 3) TF tensor
        new_points: (batch_size, npoint, nsample, 3+channel) TF tensor
        idx: (batch_size, npoint, nsample) TF tensor, indices of local points as in ndataset points
        grouped_xyz: (batch_size, npoint, nsample, 3) TF tensor, normalized point XYZs
            (subtracted by seed point XYZ) in local regions
    '''
    sample_idx = farthest_point_sample(npoint, xyz)
    new_xyz = gather_point(xyz, sample_idx) # (batch_size, npoint, 3)
    if knn:
        _,idx = knn_point(nsample, xyz, new_xyz)
    else:
        idx, pts_cnt = query_ball_point(radius, nsample, xyz, new_xyz)
    grouped_xyz = group_point(xyz, idx) # (batch_size, npoint, nsample, 3)
    grouped_xyz -= tf.tile(tf.expand_dims(new_xyz, 2), [1,1,nsample,1]) # translation normalization
    if points is not None:
        grouped_points = group_point(points, idx) # (batch_size, npoint, nsample, channel)
        if use_xyz:
            new_points = tf.concat([grouped_xyz, grouped_points], axis=-1) # (batch_size, npoint, nample, 3+channel)
        else:
            new_points = grouped_points
    else:
        new_points = grouped_xyz

    return new_xyz, new_points, idx, sample_idx, grouped_xyz 
開發者ID:xingyul,項目名稱:meteornet,代碼行數:37,代碼來源:net_utils.py

示例11: sample_and_group

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def sample_and_group(npoint, radius, nsample, xyz, points, knn=False, use_xyz=True):
    '''
    Input:
        npoint:         int32
        radius:         float32
        nsample:        int32
        xyz:            (batch_size, ndataset, 3) TF tensor
        points:         (batch_size, ndataset, channel) TF tensor, if None will just use xyz as points
        knn:            bool, if True use kNN instead of radius search
        use_xyz:        bool, if True concat XYZ with local point features, otherwise just use point features
    Output:
        new_xyz:        (batch_size, npoint, 3) TF tensor
        new_points:     (batch_size, npoint, nsample, 3+channel) TF tensor
        idx:            (batch_size, npoint, nsample) TF tensor, indices of local points as in ndataset points
        grouped_xyz:    (batch_size, npoint, nsample, 3) TF tensor, normalized point XYZs (subtracted by seed point XYZ) in local regions
    '''

    new_xyz = gather_point(xyz, farthest_point_sample(npoint, xyz))         # (batch_size, npoint, 3)
    if knn:
        _,idx = knn_point(nsample, xyz, new_xyz)
    else:
        idx, pts_cnt = query_ball_point(radius, nsample, xyz, new_xyz)

    grouped_xyz = group_point(xyz, idx)                                     # (batch_size, npoint, nsample, 3)
    grouped_xyz -= tf.tile(tf.expand_dims(new_xyz, 2), [1,1,nsample,1])     # translation normalization

    if points is not None:
        grouped_points = group_point(points, idx)                           # (batch_size, npoint, nsample, channel)
        if use_xyz:
            new_points = tf.concat([grouped_xyz, grouped_points], axis=-1)  # (batch_size, npoint, nample, 3+channel)
        else:
            new_points = grouped_points
    else:
        new_points = grouped_xyz

    return new_xyz, new_points, idx, grouped_xyz 
開發者ID:hehefan,項目名稱:PointRNN,代碼行數:38,代碼來源:pointnet2.py

示例12: sample_and_group

# 需要導入模塊: import tf_grouping [as 別名]
# 或者: from tf_grouping import query_ball_point [as 別名]
def sample_and_group(npoint, radius, nsample, xyz, points, tnet_spec=None, knn=False, use_xyz=True):
    '''
    Input:
        npoint: int32
        radius: float32
        nsample: int32
        xyz: (batch_size, ndataset, 3) TF tensor
        points: (batch_size, ndataset, channel) TF tensor, if None will just use xyz as points
        tnet_spec: dict (keys: mlp, mlp2, is_training, bn_decay), if None do not apply tnet
        knn: bool, if True use kNN instead of radius search
        use_xyz: bool, if True concat XYZ with local point features, otherwise just use point features
    Output:
        new_xyz: (batch_size, npoint, 3) TF tensor
        new_points: (batch_size, npoint, nsample, 3+channel) TF tensor
        idx: (batch_size, npoint, nsample) TF tensor, indices of local points as in ndataset points
        grouped_xyz: (batch_size, npoint, nsample, 3) TF tensor, normalized point XYZs
            (subtracted by seed point XYZ) in local regions
    '''

    new_xyz = gather_point(xyz, farthest_point_sample(npoint, xyz)) # (batch_size, npoint, 3)
    if knn:
        _,idx = knn_point(nsample, xyz, new_xyz)
    else:
        idx, pts_cnt = query_ball_point(radius, nsample, xyz, new_xyz)
    grouped_xyz = group_point(xyz, idx) # (batch_size, npoint, nsample, 3)
    grouped_xyz -= tf.tile(tf.expand_dims(new_xyz, 2), [1,1,nsample,1]) # translation normalization
    if tnet_spec is not None:
        grouped_xyz = tnet(grouped_xyz, tnet_spec)
    if points is not None:
        grouped_points = group_point(points, idx) # (batch_size, npoint, nsample, channel)
        if use_xyz:
            new_points = tf.concat([grouped_xyz, grouped_points], axis=-1) # (batch_size, npoint, nample, 3+channel)
        else:
            new_points = grouped_points
    else:
        new_points = grouped_xyz

    return new_xyz, new_points, idx, grouped_xyz 
開發者ID:ericyi,項目名稱:GSPN,代碼行數:40,代碼來源:pointnet_util.py


注:本文中的tf_grouping.query_ball_point方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。