mad*_*mad 6 python keras tensorflow
运行keras制作的CNN时出现以下错误
文件“venv/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py”,第 4185 行,在 truncated_normal 返回 tf.truncated_normal(shape,mean,stddev,dtype=dtype,seed=seed) AttributeError: module “tensorflow”没有属性“truncated_normal”
我已经安装并重新安装了 Tensorflow 2.0 好几次。可能会发生什么?
小智 6
对于TewnsorFlow 2.x和keras 2.3或以上版本,以下用法适应性更强。用户无需同时降级 TensorFlow 和 Keras。
# Add the import statements
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
# Change it to the sample expression as follows.
init = tf.compat.v1.random.truncated_normal()
Run Code Online (Sandbox Code Playgroud)
干杯!
Keras 2.2.4 不支持 TensorFlow 2.0(它的发布时间早于 TF 2.0),因此您可以将 TensorFlow 降级到版本 1.x,或者将 Keras 升级到版本 2.3,后者支持 TensorFlow 2.0。
| 归档时间: |
|
| 查看次数: |
13716 次 |
| 最近记录: |