tensorflow / fold

Deep learning with dynamic computation graphs in TensorFlow
Apache License 2.0
1.82k stars 266 forks source link

using tf.constant() in td.Composition #92

Open legend4917 opened 6 years ago

legend4917 commented 6 years ago

I got a problem recently, describe briefly as follow:

def xxx(ss):
    word = [1 for _ in range(ss)]
    return word

c = td.Composition(name="ccc")
with c.scope():
    aa = c.input
    b = tf.constant(aa)
    c.output.reads(b)

res = td.InputTransform(xxx) >> c

with tf.Session() as sess:
    print(res.eval(10))

running the code got "TypeError: Expected binary or unicode string, got <td.Composition.input 'ccc'>"

Any help would be greatly appreciated.

delesley commented 6 years ago

You can't mix TensorFlow expressions like "tf.constant", and block combinators like that. Block combinators operate on blocks, not tensors. TensorFlow code has to be wrapped in td.FromTensor or td.Function.

On Sun, Jan 21, 2018 at 11:50 PM, 朱雪林 notifications@github.com wrote:

I got a problem recently, describe briefly as follow:

`def xxx(ss): word = [1 for _ in range(ss)] return word

c = td.Composition(name="ccc") with c.scope(): aa = c.input b = tf.constant(aa) c.output.reads(b)

res = td.InputTransform(xxx) >> c

with tf.Session() as sess: print(res.eval(10)) ` running the code got TypeError: Expected binary or unicode string, got <td.Composition.input 'ccc'>

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tensorflow/fold/issues/92, or mute the thread https://github.com/notifications/unsubscribe-auth/AGGbTZAYRo3w_8kmW4TWwyF5-MQd8mr2ks5tND26gaJpZM4RmR4I .

-- DeLesley Hutchins | Software Engineer | delesley@google.com | 505-206-0315