Using SparseTensor as a trainable variable?

前端 未结 4 1946
借酒劲吻你
借酒劲吻你 2020-12-09 13:39

I\'m trying to use SparseTensor to represent weight variables in a fully-connected layer.
However, it seems that TensorFlow 0.8 doesn\'t allow to use Sp

4条回答
  •  情书的邮戳
    2020-12-09 14:11

    As a workaround to your problem, you can provide a tf.Variable (until Tensorflow v0.8) for the values of a sparse tensor. The sparsity structure has to be pre-defined in that case, the weights however remain trainable.

    weights = tf.Variable()
    sparse_var = tf.SparseTensor(, weights, )  # v0.8
    sparse_var = tf.SparseTensor(, tf.identity(weights), )  # v0.9
    

提交回复
热议问题