Reputation: 21662
I want to create node with Mul
operation and add it to existing graph.
Here is my attemp:
node1 = tf.NodeDef()
node1.name = 'MyMul1'
node1.op = 'Mul'
node1.input.extend(['conv1'])
node1.attr["T"].type = 1
The problem that I don't know how to specify constant on which input tensor in multiplied.
Upvotes: 1
Views: 418
Reputation: 171
This might not be applicable to your situation but I would strongly suggest using higher level APIs like tf.math.multiply
. If you've lost the handle to the inputs in question you can use tf.Graph.get_tensor_by_name
and tf.Graph.get_operation_by_name
.
That said, what you can do to multiply with a constant is to create a Const
op with a specified value and then use it's output as an input for this Mul
op. Example of op creation from r1.13 using tf.Graph.create_op
. Although, a higher level API like tf.constant
might suit your needs better.
Upvotes: 1