tf_coo = tf.SparseTensor(indices=np.array([[0, 0, 0, 1, 1, 2, 3, 9],
[1, 4, 9, 9, 9, 9, 9, 9]]).T,
values=[1, 2, 3, 5,1,1,1,1],
shape=[10, 10])
Ich erhalte die Fehlermeldunginitialisieren Tensoren
InvalidArgumentError (see above for traceback): indices[4] = [1,9] is repeated
[[Node: SparseToDense = SparseToDense[T=DT_INT32, Tindices=DT_INT64, validate_indices=true, _device="/job:localhost/replica:0/task:0/cpu:0"](SparseTensor/indices, SparseToDense/output_shape, SparseTensor/values, SparseToDense/default_value)]]
Ist es nicht möglich, jus konstruieren zwei Listen von Indizes und Werte zu ihnen? Ich habe vorher coo_matrix benutzt und es löst das sehr gut. Irgendeine Hilfe?
EDIT: Ich löste es durch Erstellen einer CSR_Matrix, dass ich die Funktion sort_indices() verwendet, dann habe ich es in Coo_matrix umgewandelt. Ich schaffe Von dort gerade eine SparseTensor
tf.SparseTensor(indices= (coo_martix.row, coo_martix.col), values= coo_matrix.data, dense_shape=coo_martix.shape)
Sie sollten Ihre Lösung als Antwort setzen. – daknowles