0

I'm attempting to filter a matrix that represents a point cloud in tensorflow. It is an n x 3 matrix.

I only want to keep rows with z > eps. This corresponds to column index 2 of the matrix.

I have the following code:


import numpy as np
import tensorflow as tf

point_cloud = tf.placeholder(tf.float32, shape=[None,3])
eps = tf.placeholder(tf.float32)

mask = tf.greater(point_cloud[:,2], eps)
reduced_cloud = tf.boolean_mask(point_cloud, mask)


init = tf.global_variables_initializer()

with tf.Session() as sess:
    sess.run(init)
    _cloud = np.random.rand(5000,3)
    feed = {point_cloud:_cloud, eps:0.0025}
    _filtered = sess.run(reduced_cloud, feed_dict=feed)


When I run the above code I get this:


ValueError: Number of mask dimensions must be specified, even if some dimensions are None.  E.g. shape=[None] is ok, but shape=None is not.

I don't understand the error message, having tried to specify shape in a number of places with no success, and the documentation seems to suggest the boolean_mask only works with np.arrays. Is there any way to do this entirely on the tensorflow graph?

1 Answer 1

3

You haven't specified the shape of eps which needs to be a 1D-tensor:

import numpy as np
import tensorflow as tf

point_cloud = tf.placeholder(tf.float32, shape=[None,3])
eps = tf.placeholder(tf.float32, shape=[None])

mask = tf.greater(point_cloud[:,2], eps)
reduced_cloud = tf.boolean_mask(point_cloud, mask)

init = tf.global_variables_initializer()
with tf.Session() as sess:
     sess.run(init)
     _cloud = np.random.rand(5000,3)
     feed = {point_cloud:_cloud, eps:[0.0025]}
     _filtered = sess.run(reduced_cloud, feed_dict=feed)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.