tensorflow 版本不同 报错合集

发布时间 2023-08-06 16:39:03作者: blackstrom
1、

"AttributeError: module 'tensorflow' has no attribute 'random_normal'"问题解决办法

使用

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

替换

import tensorflow as tf

 

2、tensorflow.python.framework.errors_impl.InvalidArgumentError: Input to reshape is a tensor with 196608 values, but the requested shape has 786432 [Op:Reshape]

TensorFlow报错Input to reshape is a tensor with XXX values, but the requested shape ..._tensorflow.python.framework.errors_impl.invalidarg_郑德帅的博客-CSDN博客

 3、AttributeError: module 'tensorflow' has no attribute 'Session'

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

替换

import tensorflow as tf