Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change print foo to print(foo) --> python 3 works #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not quite right. When you are printing multiple values separated by a comma then you must from __future__ import print_function at the top of the import statements to get identical output in Python 2.

$ python2 -c "print 'a', 'b' ; print('a', 'b')"

a b
('a', 'b')

#print ret


Expand Down
6 changes: 3 additions & 3 deletions tf_ops/3d_interpolation/tf_interpolate_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ def test(self):
def test_grad(self):
with self.test_session():
points = tf.constant(np.random.random((1,8,16)).astype('float32'))
print points
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
print(interpolated_points)
err = tf.test.compute_gradient_error(points, (1,8,16), interpolated_points, (1,128,16))
print err
print(err)
self.assertLess(err, 1e-4)

if __name__=='__main__':
Expand Down
2 changes: 1 addition & 1 deletion tf_ops/3d_interpolation/visu_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def fun(xyz1,xyz2,pts2):
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
print(norm)
weight = (1.0/dist) / norm
interpolated_points = three_interpolate(points, idx, weight)
with tf.Session('') as sess:
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)


8 changes: 4 additions & 4 deletions tf_ops/grouping/tf_grouping_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ def test(self):
def test_grad(self):
with tf.device('/gpu:0'):
points = tf.constant(np.random.random((1,128,16)).astype('float32'))
print points
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
print(grouped_points)

with self.test_session():
print "---- Going to compute gradient error"
print("---- Going to compute gradient error")
err = tf.test.compute_gradient_error(points, (1,128,16), grouped_points, (1,8,32,16))
print err
print(err)
self.assertLess(err, 1e-4)

if __name__=='__main__':
Expand Down
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)