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

A KerasTensor cannot be used as input to a TensorFlow function #93

Open
jp-varela opened this issue Jul 9, 2024 · 1 comment
Open

Comments

@jp-varela
Copy link

After messing around, I could not use the package on my case. So I tried to run locally your your binary classification example from here: https://deeptables.readthedocs.io/en/latest/examples.html#binary-classification

And I am getting the same error as in my use case.

System information

  • OS Platform and Distribution (e.g., CentOS 7.6):
  • Python version: 3.10.14
  • DeepTables version: 0.2.6
  • Other Python packages(run pip list):
  • tensorflow 2.8.0

Describe the current behavior
ValueError: A KerasTensor cannot be used as input to a TensorFlow function. A KerasTensor is a symbolic placeholder for a shape and dtype, used when constructing Keras Functional models or Keras Functions. You can only use it as input to a Keras layer or a Keras operation (from the namespaces keras.layers and keras.operations). You are likely doing something like:

x = Input(...)
...
tf_fn(x)  # Invalid.

What you should do instead is wrap tf_fn in a layer:

class MyLayer(Layer):
    def call(self, x):
        return tf_fn(x)

x = MyLayer()(x)`


**Standalone code to reproduce the issue**
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Jupyter notebook.
@oaksharks
Copy link
Collaborator

@jp-varela I have not replicated this issue since unable to install TensorFlow=2.8 on Python 3.10.
You can retry using TensorFlow=2.9

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