tf.sparse_placeholder

tf.sparse_placeholder是tensorflow中稀疏矩阵占位符,主要用于计算CTC的loss。从名字看,就是一个占位符用的,需要在run的时候喂数据。另外TF中还有一个稀疏矩阵张量 tf.SparseTensor。我在使用的时候一直报下面的错:

[feed.indices, feed.values, feed.dense_shape], feed_val)),
TypeError: zip argument #2 must support iteration

表示很尴尬,根据出错信息可以看出是这个稀疏矩阵出错了,我在feed的时候喂的是 

tf.SparseTensor(indices=indices, values=values, dense_shape=shape)

给我报错是什么意思?看 tf.sparse_placeholder 的源码,如下:

恍然大悟,给tf.sparse_placeholder喂数据的时候应该直接填充 (indices, values, shape),或者使用 tf.SparseTensorValue。如果使用tf.SparseTensor,需要按照下面的形式。

还是不熟悉啊!!!

猜你喜欢

转载自blog.csdn.net/haveanybody/article/details/86220140
今日推荐