如何将张量dtype = tf.float32转换为dtype = tf.float32_ref?

时间:2019-01-07 06:09:37

标签: tensorflow

I want use function tf.scatter_nd_update ,but it shows error as follows,it seems scatter_nd_update first parammeter reject  word_embeddings dtype tf.float32 .how can i convert word_embeddings from tf.float32 to float32_ref before use the function tf.scatter_nd_update?

_word_embeddings = tf.Variable(self.embeddings,
       dtype=tf.float32,
       trainable=self.update_embedding,
       name="_word_embeddings")
word_embeddings = tf.nn.embedding_lookup(params=_word_embeddings,
     ids=self.word_ids,
     name="word_embeddings")
word_embeddings_modify = tf.scatter_nd_update(word_embeddings, self.error_word, sum_all)

它显示如下错误:   在lookup_layer_op中的文件“ /zh-NER-TF-master/model.py”,第76行     word_embeddings = tf.scatter_nd_update(word_embeddings,self.error_word,sum_all)   scatter_nd_update中的文件“ /usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/state_ops.py”,第422行     ref.handle,indexs,ops.convert_to_tensor(updates,dtype = ref.dtype),

AttributeError:“ Tensor”对象没有属性“ handle”

0 个答案:

没有答案