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

如何使用tensorflow 2.x 进行训练? #41

Open
panhu opened this issue Jan 3, 2024 · 1 comment
Open

如何使用tensorflow 2.x 进行训练? #41

panhu opened this issue Jan 3, 2024 · 1 comment

Comments

@panhu
Copy link

panhu commented Jan 3, 2024

您好,我想请问下,不使用“import tensorflow.compat.v1 as tf”的情况下,使用tf 2.x进行训练,会报错:

TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='Placeholder:0', description="created by layer 'tf.cast_2'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as tf.cond, tf.function, gradient tapes, or tf.map_fn. Keras Functional model construction only supports TF API calls that do support dispatching, such as tf.math.add or tf.reshape. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer call and calling that layer on this symbolic input/output.

应该如何修改呢,非常感谢

@Le-Xiaohuai-speech
Copy link
Owner

使用全keras 接口试试?

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