DeepTables icon indicating copy to clipboard operation
DeepTables copied to clipboard

A KerasTensor cannot be used as input to a TensorFlow function

Open jp-varela opened this issue 1 year ago • 1 comments

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.

jp-varela avatar Jul 09 '24 17:07 jp-varela

@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

oaksharks avatar Jul 19 '24 08:07 oaksharks