user1241241
user1241241

Reputation: 674

ValueError while adding tensor with scalar

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?

Upvotes: 0

Views: 89

Answers (1)

Susmit Agrawal
Susmit Agrawal

Reputation: 3764

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.

Upvotes: 1

Related Questions