本文整理汇总了Python中tf_interpolate.three_nn方法的典型用法代码示例。如果您正苦于以下问题:Python tf_interpolate.three_nn方法的具体用法?Python tf_interpolate.three_nn怎么用?Python tf_interpolate.three_nn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tf_interpolate
的用法示例。
在下文中一共展示了tf_interpolate.three_nn方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fun
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
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
示例2: fun
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
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
示例3: pc_upsampling
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
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
示例4: pointnet_upsample
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
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
示例5: fun
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
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
示例6: test_grad
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
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)
示例7: pointnet_fp_module
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
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
示例8: pointnet_fp_module
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
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
示例9: pointnet_fp_module
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
def pointnet_fp_module(xyz1,
xyz2,
points1,
points2,
mlp,
last_mlp_activation=True,
scope='fp'):
''' 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):
if i == len(mlp)-1 and not(last_mlp_activation):
activation_fn = None
else:
activation_fn = tf.nn.relu
new_points1 = conv2d(inputs=new_points1, filters=num_out_channel, name='mlp_%d'%(i+1))
new_points1 = tf.squeeze(new_points1, [2]) # B,ndataset1,mlp[-1]
return new_points1
示例10: pointnet_fp_module
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
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
示例11: test_grad
# 需要导入模块: import tf_interpolate [as 别名]
# 或者: from tf_interpolate import three_nn [as 别名]
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)