如何用一个tensor给另一个tensor赋值?

 
a是一个tensor, b另一个tensor,现在我想用b给a赋值,直接写a=b显示不能赋值,那么应该用什么办法赋值呢?
已邀请:

tensorflow - CaffeCN社区Tensorflow主题站管理员 http://tensorflow.caffecn.cn

赞同来自:

 
直接赋值会报 TypeError: 'Tensor' object does not support item assignment
tensorflow里面提供了assign()函数,注意被赋值的应该是一个tensor变量 
  def assign(self, value, use_locking=False):
"""Assigns a new value to the variable.

This is essentially a shortcut for `assign(self, value)`.

Args:
value: A `Tensor`. The new value for this variable.
use_locking: If `True`, use locking during the assignment.

Returns:
A `Tensor` that will hold the new value of this variable after
the assignment has completed.
"""

要回复问题请先登录注册