这是indexloc提供的服务,不要输入任何密码
Skip to content

tf.debugging.assert_shapes() does not work for SparseTensor #36268

@terhorst

Description

@terhorst

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Mac OS X 10.15
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 2.1
  • Python version: 3.8

Describe the current behavior
tf.debugging.assert_shapes cannot be used with sparse tensors.

Describe the expected behavior
tf.debugging.assert_shapes should allow you to mix and match dense and sparse tensors when checking for dimensional consistency.

Code to reproduce the issue

import tensorflow as tf
A = tf.range(3)
tf.debugging.assert_shapes(((A, [3]),))  # works
# raises "ValueError: Attempt to convert a value (...) with an unsupported type (<class 'tensorflow.python.framework.sparse_tensor.SparseTensor'>) to a Tensor.
tf.debugging.assert_shapes(((tf.sparse.from_dense(A), [3]),))

Metadata

Metadata

Labels

TF 2.3Issues related to TF 2.3comp:opsOPs related issuestype:bugBug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions