module ‘tensorflow’ has no attribute ‘sparse_to_dense’
tensorflow2.0中把 sparse_to_dense去掉了
可以使用下面两个函数替代
1、先构造SparseTensor
tf.sparse.SparseTensor()
2、再将Sparse Tensor转Dense
tf.sparse.to_dense()
合在一起
sparse_temp = tf.sparse.SparseTensor(indices=tf.cast(full_indices, tf.int64),
values=tf.cast(tf.reshape(values, [-1]), tf.int64),
dense_shape=tf.cast(x.get_shape(), tf.int64))
to_substract = tf.sparse.to_dense(sparse_temp)
SparseTensor的参数必须为tf.int64