tf.sparse.transpose fails on SparseTensorValue and non-SparseTensor inputs

Abierto
#129,897 1 comentario 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 2 días

@Kayyuri ya está trabajando en esto.

Desde el 3/11/2026.

  • #129898 de @Hrushikesh-ramilla — abierto

Evaluación

Este issue todavía no se ha evaluado.

Descripción

2.21.0 awaiting PR merge comp:ops type:bug
Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

binary

TensorFlow version

2.21.0 / nightly

Custom code

Yes

OS platform and distribution

Windows / Linux

Python version

3.10

Current behavior?

tf.sparse.transpose raises AttributeError: 'SparseTensorValue' object has no attribute 'shape' when given a SparseTensorValue, and AttributeError: 'list' object has no attribute 'shape' when given non-SparseTensor inputs (such as a Python list).

Expected behavior:
tf.sparse.transpose should accept SparseTensorValue instances (converting them to SparseTensor as done in tf.sparse.reshape, tf.sparse.reorder, tf.sparse.slice, and tf.sparse.concat), and raise TypeError: Input must be a SparseTensor. when passed non-SparseTensor inputs, consistent with its documented Raises: TypeError: If sp_input is not a SparseTensor. contract.

Standalone code to reproduce the issue
import numpy as np
import tensorflow as tf

# 1. SparseTensorValue fails with AttributeError
sp_val = tf.compat.v1.SparseTensorValue(
    indices=np.array([[0, 1], [2, 3]]),
    values=np.array([1.0, 2.0]),
    dense_shape=np.array([4, 5]),
)
tf.sparse.transpose(sp_val)
# AttributeError: 'SparseTensorValue' object has no attribute 'shape'

# 2. Non-SparseTensor fails with AttributeError instead of documented TypeError
tf.sparse.transpose([[1, 2], [3, 4]])
# AttributeError: 'list' object has no attribute 'shape'
Lenguaje dominante
C++
Estrellas
201k
Forks
78.4k
Merge medio
3 d 1 h
PR fusionados (30 d)
433

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de tensorflow/tensorflow

Todos los issues de tensorflow/tensorflow

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.