Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: To be compatible with tf.eager.defun, Python functions must return zero or more Tensors; in compilation of <function _tf_if_stmt.<locals>.aug_body at 0x7f3d989cfb00>, found return value of type <class 'function'>, which is not a Tensor. #10

Open
poojitharamachandra opened this issue Apr 5, 2021 · 4 comments

Comments

@poojitharamachandra
Copy link

<ipython-input-16-2f54f413d530>:134 call  *
    decoder_outputs = self.odeblock(encoder_inputs)
<ipython-input-16-2f54f413d530>:75 call  *
    outputs = odeint(self.odefunc, x, integration_time)
/usr/local/lib/python3.7/dist-packages/tfdiffeq/odeint.py:68 odeint  *
    tensor_input, func, y0, t = _check_inputs(func, y0, t)
/usr/local/lib/python3.7/dist-packages/tfdiffeq/misc.py:317 _check_inputs  *
    if _decreasing(t):
/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/operators/control_flow.py:1163 if_stmt
    _tf_if_stmt(cond, body, orelse, get_state, set_state, symbol_names, nouts)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/operators/control_flow.py:1210 _tf_if_stmt
    cond, aug_body, aug_orelse, strict=True)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/dispatch.py:201 wrapper
    return target(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/deprecation.py:538 new_func
    return func(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/control_flow_ops.py:1180 cond
    return cond_v2.cond_v2(pred, true_fn, false_fn, name)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/cond_v2.py:89 cond_v2
    op_return_value=pred)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py:995 func_graph_from_py_func
    expand_composites=True)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/nest.py:659 map_structure
    structure[0], [func(*x) for x in entries],
/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/nest.py:659 <listcomp>
    structure[0], [func(*x) for x in entries],
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py:952 convert
    (str(python_func), type(x)))

TypeError: To be compatible with tf.eager.defun, Python functions must return zero or more Tensors; in compilation of <function _tf_if_stmt.<locals>.aug_body at 0x7f3d989cfb00>, found return value of type <class 'function'>, which is not a Tensor.
@poojitharamachandra
Copy link
Author

Hi,
Gentle Reminder!
Could you please check this

@titu1994
Copy link
Owner

titu1994 commented Apr 9, 2021

The error mentions to return a tensor, not a function. Can you check your return statement to make you return one or more tensors ?

@poojitharamachandra
Copy link
Author

poojitharamachandra commented Apr 9, 2021

actually , the error is because of the function : _check_inputs

/usr/local/lib/python3.7/dist-packages/tfdiffeq/odeint.py:68 odeint *
tensor_input, func, y0, t = _check_inputs(func, y0, t)
/usr/local/lib/python3.7/dist-packages/tfdiffeq/misc.py:317 _check_inputs *
if _decreasing(t):

@poojitharamachandra
Copy link
Author

Hi,
Gentle Reminder!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants