Skip to content

Commit

Permalink
Bump to python3
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhaiyu committed May 4, 2020
1 parent 4292663 commit 2945fed
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions tf_ops/3d_interpolation/tf_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def _three_interpolate_grad(op, grad_out):
now = time.time()
for _ in range(100):
ret = sess.run(interpolated_points)
print time.time() - now
print ret.shape, ret.dtype
print(time.time() - now)
print(ret.shape, ret.dtype)
#print ret


Expand Down
14 changes: 7 additions & 7 deletions tf_ops/grouping/tf_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ def knn_point(k, xyz1, xyz2):
n = xyz1.get_shape()[1].value
c = xyz1.get_shape()[2].value
m = xyz2.get_shape()[1].value
print b, n, c, m
print xyz1, (b,1,n,c)
print(b, n, c, m)
print(xyz1, (b,1,n,c))
xyz1 = tf.tile(tf.reshape(xyz1, (b,1,n,c)), [1,m,1,1])
xyz2 = tf.tile(tf.reshape(xyz2, (b,m,1,c)), [1,1,n,1])
dist = tf.reduce_sum((xyz1-xyz2)**2, -1)
print dist, k
print(dist, k)
outi, out = select_top_k(k, dist)
idx = tf.slice(outi, [0,0,0], [-1,-1,k])
val = tf.slice(out, [0,0,0], [-1,-1,k])
print idx, val
print(idx, val)
#val, idx = tf.nn.top_k(-dist, k=k) # ONLY SUPPORT CPU
return val, idx

Expand Down Expand Up @@ -98,8 +98,8 @@ def knn_point(k, xyz1, xyz2):
now = time.time()
for _ in range(100):
ret = sess.run(grouped_points)
print time.time() - now
print ret.shape, ret.dtype
print ret
print(time.time() - now)
print(ret.shape, ret.dtype)
print(ret)


6 changes: 3 additions & 3 deletions tf_ops/sampling/tf_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ def farthest_point_sample(npoint,inp):
us=(uplusv+uminusv)*0.5
vs=(uplusv-uminusv)*0.5
pt_sample=tria_sample+(trib_sample-tria_sample)*tf.expand_dims(us,-1)+(tric_sample-tria_sample)*tf.expand_dims(vs,-1)
print 'pt_sample: ', pt_sample
print('pt_sample: ', pt_sample)
reduced_sample=gather_point(pt_sample,farthest_point_sample(1024,pt_sample))
print reduced_sample
print(reduced_sample)
with tf.Session('') as sess:
ret=sess.run(reduced_sample)
print ret.shape,ret.dtype
print(ret.shape,ret.dtype)
import cPickle as pickle
pickle.dump(ret,open('1.pkl','wb'),-1)
2 changes: 1 addition & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def train():
accuracy = tf.reduce_sum(tf.cast(correct, tf.float32)) / float(BATCH_SIZE)
tf.summary.scalar('accuracy', accuracy)

print "--- Get training operator"
print("--- Get training operator")
# Get training operator
learning_rate = get_learning_rate(batch)
tf.summary.scalar('learning_rate', learning_rate)
Expand Down
14 changes: 7 additions & 7 deletions utils/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def rotate_point_cloud(batch_data):
BxNx3 array, rotated batch of point clouds
"""
rotated_data = np.zeros(batch_data.shape, dtype=np.float32)
for k in xrange(batch_data.shape[0]):
for k in range(batch_data.shape[0]):
rotation_angle = np.random.uniform() * 2 * np.pi
cosval = np.cos(rotation_angle)
sinval = np.sin(rotation_angle)
Expand All @@ -58,7 +58,7 @@ def rotate_point_cloud_z(batch_data):
BxNx3 array, rotated batch of point clouds
"""
rotated_data = np.zeros(batch_data.shape, dtype=np.float32)
for k in xrange(batch_data.shape[0]):
for k in range(batch_data.shape[0]):
rotation_angle = np.random.uniform() * 2 * np.pi
cosval = np.cos(rotation_angle)
sinval = np.sin(rotation_angle)
Expand All @@ -76,7 +76,7 @@ def rotate_point_cloud_with_normal(batch_xyz_normal):
Output:
B,N,6, rotated XYZ, normal point cloud
'''
for k in xrange(batch_xyz_normal.shape[0]):
for k in range(batch_xyz_normal.shape[0]):
rotation_angle = np.random.uniform() * 2 * np.pi
cosval = np.cos(rotation_angle)
sinval = np.sin(rotation_angle)
Expand All @@ -97,7 +97,7 @@ def rotate_perturbation_point_cloud_with_normal(batch_data, angle_sigma=0.06, an
BxNx3 array, rotated batch of point clouds
"""
rotated_data = np.zeros(batch_data.shape, dtype=np.float32)
for k in xrange(batch_data.shape[0]):
for k in range(batch_data.shape[0]):
angles = np.clip(angle_sigma*np.random.randn(3), -angle_clip, angle_clip)
Rx = np.array([[1,0,0],
[0,np.cos(angles[0]),-np.sin(angles[0])],
Expand All @@ -124,7 +124,7 @@ def rotate_point_cloud_by_angle(batch_data, rotation_angle):
BxNx3 array, rotated batch of point clouds
"""
rotated_data = np.zeros(batch_data.shape, dtype=np.float32)
for k in xrange(batch_data.shape[0]):
for k in range(batch_data.shape[0]):
#rotation_angle = np.random.uniform() * 2 * np.pi
cosval = np.cos(rotation_angle)
sinval = np.sin(rotation_angle)
Expand All @@ -144,7 +144,7 @@ def rotate_point_cloud_by_angle_with_normal(batch_data, rotation_angle):
BxNx6 array, rotated batch of point clouds iwth normal
"""
rotated_data = np.zeros(batch_data.shape, dtype=np.float32)
for k in xrange(batch_data.shape[0]):
for k in range(batch_data.shape[0]):
#rotation_angle = np.random.uniform() * 2 * np.pi
cosval = np.cos(rotation_angle)
sinval = np.sin(rotation_angle)
Expand All @@ -167,7 +167,7 @@ def rotate_perturbation_point_cloud(batch_data, angle_sigma=0.06, angle_clip=0.1
BxNx3 array, rotated batch of point clouds
"""
rotated_data = np.zeros(batch_data.shape, dtype=np.float32)
for k in xrange(batch_data.shape[0]):
for k in range(batch_data.shape[0]):
angles = np.clip(angle_sigma*np.random.randn(3), -angle_clip, angle_clip)
Rx = np.array([[1,0,0],
[0,np.cos(angles[0]),-np.sin(angles[0])],
Expand Down

0 comments on commit 2945fed

Please sign in to comment.