Python tf_interpolate.three_nn() Examples
The following are 30
code examples of tf_interpolate.three_nn().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tf_interpolate
, or try the search function
.
Example #1
Source File: visu_interpolation.py From deep-functional-dictionaries with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #2
Source File: visu_interpolation.py From articulated-part-induction with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #3
Source File: visu_interpolation.py From frustum-pointnets with Apache License 2.0 | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print(norm) weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #4
Source File: visu_interpolation.py From flownet3d with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #5
Source File: visu_interpolation.py From JSNet with MIT License | 6 votes |
def fun(xyz1, xyz2, pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2, 0)) xyz1 = tf.constant(np.expand_dims(xyz1, 0)) xyz2 = tf.constant(np.expand_dims(xyz2, 0)) dist, idx = three_nn(xyz1, xyz2) # weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0 / dist), axis=2, keep_dims=True) norm = tf.tile(norm, [1, 1, 3]) print(norm) weight = (1.0 / dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp, pts1, d, w = sess.run([xyz1, interpolated_points, dist, weight]) # print w pts1 = pts1.squeeze() return pts1
Example #6
Source File: pointnet_util.py From JSNet with MIT License | 6 votes |
def pointnet_upsample(xyz1, xyz2, points2, scope): """ PointNet Feature Propogation (FP) Module Input: xyz1: (batch_size, ndataset1, 3) TF tensor xyz2: (batch_size, ndataset2, 3) TF tensor, sparser than xyz1 points2: (batch_size, ndataset2, nchannel2) TF tensor Return: new_points: (batch_size, ndataset1, nchannel2) TF tensor """ with tf.variable_scope(scope) as sc: dist, idx = three_nn(xyz1, xyz2) dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0 / dist), axis=2, keep_dims=True) norm = tf.tile(norm, [1, 1, 3]) weight = (1.0 / dist) / norm interpolated_points = three_interpolate(points2, idx, weight) # B x ndataset1 x nchannel2 return interpolated_points
Example #7
Source File: visu_interpolation.py From CalibNet with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #8
Source File: tf_util.py From scanobjectnn with MIT License | 6 votes |
def pc_upsampling(xyz_upsample, xyz, feat, scope='upsampling'): """ Fully connected layer with non-linear operation. Args: xyz_upsample: 3-D tensor B x N2 x 3 xyz: 3-D tensor B x N x 3 feat: 3-D tensor B x N x C Returns: feat_upsample: 3-D tensor B x N2 x C """ with tf.variable_scope(scope) as sc: dist, idx_de = three_nn(xyz_upsample, xyz) dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm,[1,1,3]) weight = (1.0/dist) / norm feat_upsample = three_interpolate(feat, idx_de, weight) return feat_upsample
Example #9
Source File: visu_interpolation.py From scanobjectnn with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #10
Source File: visu_interpolation.py From dfc2019 with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #11
Source File: visu_interpolation.py From reading-frustum-pointnets-code with Apache License 2.0 | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print(norm) weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #12
Source File: visu_interpolation.py From GSPN with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #13
Source File: visu_interpolation.py From SpiderCNN with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #14
Source File: tf_util.py From SpiderCNN with MIT License | 6 votes |
def pc_upsampling(xyz_upsample, xyz, feat, scope='upsampling'): """ Fully connected layer with non-linear operation. Args: xyz_upsample: 3-D tensor B x N2 x 3 xyz: 3-D tensor B x N x 3 feat: 3-D tensor B x N x C Returns: feat_upsample: 3-D tensor B x N2 x C """ with tf.variable_scope(scope) as sc: dist, idx_de = three_nn(xyz_upsample, xyz) dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm,[1,1,3]) weight = (1.0/dist) / norm feat_upsample = three_interpolate(feat, idx_de, weight) return feat_upsample
Example #15
Source File: visu_interpolation.py From Geo-CNN with Apache License 2.0 | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print(norm) weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #16
Source File: visu_interpolation.py From ASIS with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #17
Source File: visu_interpolation.py From SPFN with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #18
Source File: visu_interpolation.py From meteornet with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print(norm) weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #19
Source File: visu_interpolation.py From PointRNN with MIT License | 6 votes |
def fun(xyz1,xyz2,pts2): with tf.device('/cpu:0'): points = tf.constant(np.expand_dims(pts2,0)) xyz1 = tf.constant(np.expand_dims(xyz1,0)) xyz2 = tf.constant(np.expand_dims(xyz2,0)) dist, idx = three_nn(xyz1, xyz2) #weight = tf.ones_like(dist)/3.0 dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm, [1,1,3]) print norm weight = (1.0/dist) / norm interpolated_points = three_interpolate(points, idx, weight) with tf.Session('') as sess: tmp,pts1,d,w = sess.run([xyz1, interpolated_points, dist, weight]) #print w pts1 = pts1.squeeze() return pts1
Example #20
Source File: tf_interpolate_op_test.py From flownet3d with MIT License | 5 votes |
def test_grad(self): with self.test_session(): points = tf.constant(np.random.random((1,8,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')) dist, idx = three_nn(xyz1, xyz2) weight = tf.ones_like(dist)/3.0 interpolated_points = three_interpolate(points, idx, weight) print interpolated_points err = tf.test.compute_gradient_error(points, (1,8,16), interpolated_points, (1,128,16)) print err self.assertLess(err, 1e-4)
Example #21
Source File: tf_interpolate_op_test.py From scanobjectnn with MIT License | 5 votes |
def test_grad(self): with self.test_session(): points = tf.constant(np.random.random((1,8,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')) dist, idx = three_nn(xyz1, xyz2) weight = tf.ones_like(dist)/3.0 interpolated_points = three_interpolate(points, idx, weight) print interpolated_points err = tf.test.compute_gradient_error(points, (1,8,16), interpolated_points, (1,128,16)) print err self.assertLess(err, 1e-4)
Example #22
Source File: tf_interpolate_op_test.py From CalibNet with MIT License | 5 votes |
def test_grad(self): with self.test_session(): points = tf.constant(np.random.random((1,8,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')) dist, idx = three_nn(xyz1, xyz2) weight = tf.ones_like(dist)/3.0 interpolated_points = three_interpolate(points, idx, weight) print interpolated_points err = tf.test.compute_gradient_error(points, (1,8,16), interpolated_points, (1,128,16)) print err self.assertLess(err, 1e-4)
Example #23
Source File: pointnet_util.py From ASIS with MIT License | 5 votes |
def pointnet_fp_module(xyz1, xyz2, points1, points2, mlp, is_training, bn_decay, scope, bn=True): ''' PointNet Feature Propogation (FP) Module Input: xyz1: (batch_size, ndataset1, 3) TF tensor xyz2: (batch_size, ndataset2, 3) TF tensor, sparser than xyz1 points1: (batch_size, ndataset1, nchannel1) TF tensor points2: (batch_size, ndataset2, nchannel2) TF tensor mlp: list of int32 -- output size for MLP on each point Return: new_points: (batch_size, ndataset1, mlp[-1]) TF tensor ''' with tf.variable_scope(scope) as sc: dist, idx = three_nn(xyz1, xyz2) dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm,[1,1,3]) weight = (1.0/dist) / norm interpolated_points = three_interpolate(points2, idx, weight) if points1 is not None: new_points1 = tf.concat(axis=2, values=[interpolated_points, points1]) # B,ndataset1,nchannel1+nchannel2 else: new_points1 = interpolated_points new_points1 = tf.expand_dims(new_points1, 2) for i, num_out_channel in enumerate(mlp): new_points1 = tf_util.conv2d(new_points1, num_out_channel, [1,1], padding='VALID', stride=[1,1], bn=bn, is_training=is_training, scope='conv_%d'%(i), bn_decay=bn_decay) new_points1 = tf.squeeze(new_points1, [2]) # B,ndataset1,mlp[-1] return new_points1
Example #24
Source File: pointnet_util.py From JSNet with MIT License | 5 votes |
def pointnet_fp_module(xyz1, xyz2, points1, points2, mlp, is_training, bn_decay, scope, bn=True, is_dist=False): ''' PointNet Feature Propogation (FP) Module Input: xyz1: (batch_size, ndataset1, 3) TF tensor xyz2: (batch_size, ndataset2, 3) TF tensor, sparser than xyz1 points1: (batch_size, ndataset1, nchannel1) TF tensor points2: (batch_size, ndataset2, nchannel2) TF tensor mlp: list of int32 -- output size for MLP on each point Return: new_points: (batch_size, ndataset1, mlp[-1]) TF tensor ''' with tf.variable_scope(scope) as sc: dist, idx = three_nn(xyz1, xyz2) dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0 / dist), axis=2, keep_dims=True) norm = tf.tile(norm, [1, 1, 3]) weight = (1.0 / dist) / norm interpolated_points = three_interpolate(points2, idx, weight) if points1 is not None: new_points1 = tf.concat(axis=2, values=[interpolated_points, points1]) # B,ndataset1,nchannel1+nchannel2 else: new_points1 = interpolated_points new_points1 = tf.expand_dims(new_points1, 2) for i, num_out_channel in enumerate(mlp): new_points1 = tf_util.conv2d(new_points1, num_out_channel, [1, 1], padding='VALID', stride=[1, 1], bn=bn, is_training=is_training, scope='conv_%d' % (i), bn_decay=bn_decay, is_dist=is_dist) new_points1 = tf.squeeze(new_points1, [2]) # B,ndataset1,mlp[-1] return new_points1
Example #25
Source File: tf_interpolate_op_test.py From JSNet with MIT License | 5 votes |
def test_grad(self): with self.test_session(): points = tf.constant(np.random.random((1, 8, 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')) dist, idx = three_nn(xyz1, xyz2) weight = tf.ones_like(dist) / 3.0 interpolated_points = three_interpolate(points, idx, weight) print(interpolated_points) err = tf.test.compute_gradient_error(points, (1, 8, 16), interpolated_points, (1, 128, 16)) print(err) self.assertLess(err, 1e-4)
Example #26
Source File: tf_interpolate_op_test.py From meteornet with MIT License | 5 votes |
def test_grad(self): with self.test_session(): points = tf.constant(np.random.random((1,8,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')) dist, idx = three_nn(xyz1, xyz2) weight = tf.ones_like(dist)/3.0 interpolated_points = three_interpolate(points, idx, weight) print interpolated_points err = tf.test.compute_gradient_error(points, (1,8,16), interpolated_points, (1,128,16)) print err self.assertLess(err, 1e-4)
Example #27
Source File: pointnet_util.py From flownet3d with MIT License | 5 votes |
def pointnet_fp_module(xyz1, xyz2, points1, points2, mlp, is_training, bn_decay, scope, bn=True, last_mlp_activation=True): ''' PointNet Feature Propogation (FP) Module Input: xyz1: (batch_size, ndataset1, 3) TF tensor xyz2: (batch_size, ndataset2, 3) TF tensor, sparser than xyz1 points1: (batch_size, ndataset1, nchannel1) TF tensor points2: (batch_size, ndataset2, nchannel2) TF tensor mlp: list of int32 -- output size for MLP on each point Return: new_points: (batch_size, ndataset1, mlp[-1]) TF tensor ''' with tf.variable_scope(scope) as sc: dist, idx = three_nn(xyz1, xyz2) dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True) norm = tf.tile(norm,[1,1,3]) weight = (1.0/dist) / norm interpolated_points = three_interpolate(points2, idx, weight) if points1 is not None: new_points1 = tf.concat(axis=2, values=[interpolated_points, points1]) # B,ndataset1,nchannel1+nchannel2 else: new_points1 = interpolated_points new_points1 = tf.expand_dims(new_points1, 2) for i, num_out_channel in enumerate(mlp): if i == len(mlp)-1 and not(last_mlp_activation): activation_fn = None else: activation_fn = tf.nn.relu new_points1 = tf_util.conv2d(new_points1, num_out_channel, [1,1], padding='VALID', stride=[1,1], bn=bn, is_training=is_training, scope='conv_%d'%(i), bn_decay=bn_decay, activation_fn=activation_fn) new_points1 = tf.squeeze(new_points1, [2]) # B,ndataset1,mlp[-1] return new_points1
Example #28
Source File: tf_interpolate_op_test.py From deep-functional-dictionaries with MIT License | 5 votes |
def test_grad(self): with self.test_session(): points = tf.constant(np.random.random((1,8,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')) dist, idx = three_nn(xyz1, xyz2) weight = tf.ones_like(dist)/3.0 interpolated_points = three_interpolate(points, idx, weight) print interpolated_points err = tf.test.compute_gradient_error(points, (1,8,16), interpolated_points, (1,128,16)) print err self.assertLess(err, 1e-4)
Example #29
Source File: net_utils.py From meteornet with MIT License | 5 votes |
def pointnet_fp_module(xyz1, xyz2, points1, points2, mlp, is_training, bn_decay, scope, bn=True): ''' PointNet Feature Propogation (FP) Module Input: xyz1: (batch_size, ndataset1, 3) TF tensor xyz2: (batch_size, ndataset2, 3) TF tensor, sparser than xyz1 points1: (batch_size, ndataset1, nchannel1) TF tensor points2: (batch_size, ndataset2, nchannel2) TF tensor mlp: list of int32 -- output size for MLP on each point Return: new_points: (batch_size, ndataset1, mlp[-1]) TF tensor ''' with tf.variable_scope(scope) as sc: dist, idx = three_nn(xyz1, xyz2) dist = tf.maximum(dist, 1e-10) norm = tf.reduce_sum((1.0/dist),axis=2, keepdims=True) norm = tf.tile(norm,[1,1,3]) weight = (1.0/dist) / norm interpolated_points = three_interpolate(points2, idx, weight) if points1 is not None: new_points1 = tf.concat(axis=2, values=[interpolated_points, points1]) # B,ndataset1,nchannel1+nchannel2 else: new_points1 = interpolated_points new_points1 = tf.expand_dims(new_points1, 2) for i, num_out_channel in enumerate(mlp): new_points1 = tf_util.conv2d(new_points1, num_out_channel, [1,1], padding='VALID', stride=[1,1], bn=bn, is_training=is_training, scope='conv_%d'%(i), bn_decay=bn_decay) new_points1 = tf.squeeze(new_points1, [2]) # B,ndataset1,mlp[-1] return new_points1
Example #30
Source File: tf_interpolate_op_test.py From frustum-pointnets with Apache License 2.0 | 5 votes |
def test_grad(self): with self.test_session(): points = tf.constant(np.random.random((1,8,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')) dist, idx = three_nn(xyz1, xyz2) weight = tf.ones_like(dist)/3.0 interpolated_points = three_interpolate(points, idx, weight) print(interpolated_points) err = tf.test.compute_gradient_error(points, (1,8,16), interpolated_points, (1,128,16)) print(err) self.assertLess(err, 1e-4)