module 'tensorflow' has no attribute 'sparse_to_dense'
·
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
新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。
更多推荐



所有评论(0)