Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Tensor' object has no attribute 'assign_add' #1

Open
buntys2010 opened this issue Jan 2, 2020 · 0 comments
Open

Comments

@buntys2010
Copy link

I tried to implement the code in TF2.0 version and i received below error

opt/conda/lib/python3.6/site-packages/tensorflow_core/python/distribute/distribute_lib.py in _update(self, var, fn, args, kwargs, group)
   2172     # The implementations of _update() and _update_non_slot() are identical
   2173     # except _update() passes `var` as the first argument to `fn()`.
-> 2174     return self._update_non_slot(var, fn, (var,) + tuple(args), kwargs, group)
   2175 
   2176   def _update_non_slot(self, colocate_with, fn, args, kwargs, should_group):

/opt/conda/lib/python3.6/site-packages/tensorflow_core/python/distribute/distribute_lib.py in _update_non_slot(self, colocate_with, fn, args, kwargs, should_group)
   2178     # once that value is used for something.
   2179     with UpdateContext(colocate_with):
-> 2180       result = fn(*args, **kwargs)
   2181       if should_group:
   2182         return result

/opt/conda/lib/python3.6/site-packages/tensorflow_core/python/keras/optimizer_v2/optimizer_v2.py in apply_grad_to_update_var(var, grad)
    464           apply_kwargs["apply_state"] = apply_state
    465         return self._resource_apply_sparse_duplicate_indices(
--> 466             grad.values, var, grad.indices, **apply_kwargs)
    467 
    468       if "apply_state" in self._dense_apply_args:

/opt/conda/lib/python3.6/site-packages/tensorflow_core/python/keras/optimizer_v2/optimizer_v2.py in _resource_apply_sparse_duplicate_indices(self, grad, handle, indices, **kwargs)
    901         values=grad, indices=indices)
    902     return self._resource_apply_sparse(summed_grad, handle, unique_indices,
--> 903                                        **kwargs)
    904 
    905   def _resource_apply_sparse(self, grad, handle, indices, apply_state):

<ipython-input-65-ccec5cd7a8c1> in _resource_apply_sparse(self, grad, var, indices, apply_state)
    186                 r_t,
    187                 lambda_ * var,
--> 188                 use_locking=self._use_locking,
    189             )
    190             with ops.control_dependencies([r_t]):

/opt/conda/lib/python3.6/site-packages/tensorflow_core/python/ops/state_ops.py in assign_add(ref, value, use_locking, name)
    193     return gen_state_ops.assign_add(
    194         ref, value, use_locking=use_locking, name=name)
--> 195   return ref.assign_add(value)
    196 
    197 

AttributeError: 'Tensor' object has no attribute 'assign_add'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant