fold icon indicating copy to clipboard operation
fold copied to clipboard

using tf.constant() in td.Composition

Open legend4917 opened this issue 7 years ago • 1 comments

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.

legend4917 avatar Jan 22 '18 07:01 legend4917

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, 朱雪林 [email protected] 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 | [email protected] | 505-206-0315

delesley avatar Jan 22 '18 17:01 delesley