AttributeError: module 'tensorflow' has no attribute 'placeholder'
时间: 2023-09-20 15:06:24 浏览: 66
This error occurs when you are trying to use the placeholder function of TensorFlow but it is not recognized by the module. This is most likely because you are using a version of TensorFlow that does not support the placeholder function.
To resolve this issue, you can try updating your TensorFlow version to the latest one by running the following command in your terminal:
```
pip install --upgrade tensorflow
```
If this does not work, you may need to modify your code to use a different approach for defining placeholders. For example, in TensorFlow 2.0 and later versions, you can use the `tf.keras.Input` function to create input placeholders.
```
import tensorflow as tf
# Define input placeholders
inputs = tf.keras.Input(shape=(10,))
```
阅读全文