0

I'm using the following code to add tensor with scalar as follows,

self.seen  = tf.compat.v1.assign_add(self.seen , 1.)

Unfotunately it throws the following error,

> ValueError: Operation name: "AssignAddVariableOp" op:
> "AssignAddVariableOp" input: "AssignAddVariableOp/Variable" input:
> "Const" attr {   key: "dtype"   value {
>     type: DT_FLOAT   } }  is not an element of this graph.

what am I missing?

1 Answer 1

1

According to Tensorflow docs,

Unlike tf.math.add, this op does not broadcast. ref and value must have the same shape.

So you can't use this to add scalars and tensors.

Sign up to request clarification or add additional context in comments.

1 Comment

Why don't you use tf.add or simply +?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.