AttributeError: module 'tensorflow' has no attribute 'placeholder'
时间: 2023-09-17 08:12:14 浏览: 47
This error occurs when you're trying to use the `placeholder` function in TensorFlow, but it's not available in the version of TensorFlow you're using.
In TensorFlow 2.0 and later versions, the `placeholder` function has been removed and replaced with the `tf.keras.Input` function. So, instead of using `placeholder`, you can use `tf.keras.Input` to create an input tensor.
Here's an example of how you can replace `placeholder` with `tf.keras.Input`:
```
import tensorflow as tf
# Define your input shape
input_shape = (None, 28, 28, 1)
# Create an input tensor using tf.keras.Input
inputs = tf.keras.Input(shape=input_shape)
# Continue with the rest of your model
...
```
If you're using an older version of TensorFlow and need to use `placeholder`, you can try downgrading your TensorFlow version or installing an older version of TensorFlow that still supports `placeholder`.
阅读全文