Tensorflow: why passing dense matrix is noticeably faster than sparse?

Viewed 325

I am trying to use tensorflow 0.14 to train a recommendation system using collaborative filtering algorithm.

If I have

ratings = tf.sparse_placeholder(tf.float32, shape=[None, None])
ratings_dense = tf.sparse_tensor_to_dense(ratings, validate_indices=False)

and later use ratings_dense in all calculations, it is significantly (10x) slower than having

ratings_dense = tf.placeholder(tf.float32, shape=[None, None])

and passing prefilled numpy array.

Why is that so?

0 Answers
Related