Open coopie opened 7 years ago
Hi, coopie: I tried code as yours:
c = td.Composition()
with c.scope():
x = td.Vector(3).reads(c.input)
x_squared = td.Function(tf.mul).reads(x, x)
ten = td.FromTensor(10 * np.ones(3, dtype='float32'))
ten_x = td.Function(tf.mul).reads(ten, x)
c.output.reads(td.Function(tf.add).reads(x_squared, ten_x)) # BTW. You missed one ')' here :)
c.eval([1,2,3])
And then output:
array([ 11., 24., 39.], dtype=float32)
About mul
and multiply
:
You can check functions at api_docs
The number of functions startswith 'tf.mul' is only 2. (tf.multinomial and tf.multiply). Maybe tf.mul
doesn't exist now.
And about the error:
You said that "when run with the change", I think maybe you're using Ipython
or Jupyter Notebook
, if so, kill your python kernal and restart one(or you can change the composition name from c
to c_tmp
). If one block is connected, it can't be connected again.
I saw this just now, perhaps it helps:
def test_composition_raises_double_connect_output(self):
a = tdb.Scalar()
b = tdb.Scalar()
c = tdb.Composition([a, b])
c.connect(a, c.output)
self.assertRaisesWithLiteralMatch(
ValueError,
'input of block is already connected: <td.Composition.output>',
c.connect, b, c.output)
The example:
does not run properly with modern tensorflow - the
tf.mul
s need to be changed tomultiply
On top of that: when run with the name change, it throws an error:
using python3.6 ubuntu 16.04