1***
AssertionError: Bad argument number for Name: 3, expecting 4
解决:
pip install gast==0.2.2 #0.3.2版本的问题,降级后可以
2***
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'
解决:
pip install numpy==1.16.4 #版本不兼容
3***
ValueError: Variable conv1/Conv/weights already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:
解决:
需要清除计算图,重新打开python控制台。或者通过在脚本的开头放置这一行来做到这一点:
tf.reset_default_graph()
4***
IndexError: list index out of range
解决:
1.list下标超出范围。例如:list[index] ,index超出范围
2.list是空的,没有一个元素。例如:a=[],进行a[0] 就会报错。
5***
TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, numpy ndarrays, or TensorHandles.
解决
sess.run()的feed_dict参数只接受非tensor类型,需要将tensor对象转换为numpy。
batch_xs, batch_ys = sess.run([batch_x, batch_y])#将tensor对象转换为numpy
sess.run([accuracy,train_op], feed_dict={ x: batch_xs, y: batch_ys, })
6***
ValueError: Cannot feed value of shape (280, 2) for Tensor 'Placeholder:0',which has shape '(?, 1, 2)'
解决:
TensorFlow无法为Tensor’占位符:0 '(?, 1, 2)'提供错误形状值(280, 2)
而Placeholder0: x = tf.placeholder(tf.float32, [None,n_steps, n_inputs])
batch_xs, batch_ys = sess.run([batch_x, batch_y])
batch_xs = batch_xs.reshape([batch_size, n_steps, n_inputs])#改变喂入数组对象形状
sess.run([accuracy,train_op], feed_dict={ x: batch_xs, y: batch_ys, })
7***
INFO:tensorflow:Error reported to Coordinator: , Expect 258 fields but have 1 in record 0
[[{{node DecodeCSV}}]]
InvalidArgumentError: Expect 258 fields but have 1 in record 0
[[{{node DecodeCSV}}]]
解决:
CSV文件数据最后有多余的空行,删除它错误消失。
8***
FailedPreconditionError: Attempting to use uninitialized value Variable
出处:
global_step=tf.Variable(0,trainable=False)
tf.global_variables_initializer()
解决:
初始化变量后需要run
tf.global_variables_initializer().run()
9***
UnimplementedError: Fused conv implementation does not support grouped convolutions for now.
[[node layer3-c2/Relu (defined at E:/python-study-everyday project/NET5.py:62) ]]
出处:
LeNet5-MNIST
conv2_w=tf.get_variable("w",[conv2_size,conv2_size,num_channels,conv2_deep],initializer=tf.truncated_normal_initializer(stddev=0.1))
conv2_b=tf.get_variable("b",[conv2_deep],initializer=tf.constant_initializer(0.0))
conv2=tf.nn.conv2d(pool1,conv2_w,strides=[1,1,1,1],padding='SAME')
relu2=tf.nn.relu(tf.nn.bias_add(conv2,conv2_b))
解决:
conv2_w维度错误,导致卷积conv2d及激活函数relu中的维度都与上一层对应错误
conv2_w=tf.get_variable("w",[conv2_size,conv2_size,conv1_deep,conv2_deep],initializer=tf.truncated_normal_initializer(stddev=0.1))
10***
InvalidArgumentError: Received a label value of 9 which is outside the valid range of [0, 1). Label values:.....
[[node SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at E:/python-study-everyday project/NET5.py:116) ]]
Errors may have originated from an input operation.
Input Source operations connected to node SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits:
layer6-fc2/add (defined at E:/python-study-everyday project/NET5.py:100)
出处:
LeNet5-MNIST
fc2_w=tf.get_variable('w',[fc_size,num_channels],initializer=tf.truncated_normal_initializer(stddev=0.1))
if regularizer is not None:
tf.add_to_collection('losses',regularizer(fc2_w))
fc2_b=tf.get_variable("b",[num_channels],initializer=tf.constant_initializer(0.1))
100行: logit =tf.matmul(fc1,fc2_w)+fc2_b
116行: cross_entropy=tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.argmax(y_,1))
解决:
输出维度错误导致求cross_entropy出问题,num_channels=1,应该改为num_labels=10
fc2_w=tf.get_variable('w',[fc_size,num_labels],initializer=tf.truncated_normal_initializer(stddev=0.1))
fc2_b=tf.get_variable("b",[num_labels],initializer=tf.constant_initializer(0.1))
11**
*
(tensorflow) C:\WINDOWS\system32>pip install scipy==1.2.1 -i https://mirrors.aliyun.com/pypi/simple/
Collecting scipy==1.2.1
Using cached https://mirrors.aliyun.com/pypi/packages/b9/a2/62f77d2d3c42364d45ba714b4bdf7e1c4dfa67091dc9f614fa5a948b4fb4/scipy-1.2.1-cp36-cp36m-win_amd64.whl
Requirement already satisfied: numpy>=1.8.2 in g:\anaconda3\envs\tensorflow\lib\site-packages (from scipy==1.2.1)
Installing collected packages: scipy
..............
PermissionError: [Errno 13] Permission denied: 'G:\\Anaconda3\\envs\\tensorflow\\Lib\\site-packages\\scipy\\linalg\\cython_blas.cp36-win_amd64.pyd'
解决:
关闭打开的python解释器及环境。
12**
*
AttributeError: module 'h5py' has no attribute 'Group'
解决:
pip install h5py==2.8.0rc1
13**
*
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor, file C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp, line 9781
Traceback (most recent call last):
File "D:/soft-ware/pycharmproject/main.py", line 120, in
predict()
File "D:/soft-ware/pycharmproject/main.py", line 85, in predict
img = cv2.cvtColor(img, cv2.COLOR_BGR2YCrCb)
cv2.error: C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:9781: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
出处:
IMG_NAME = "./Test/Set14/butterfly_GT.bmp"
img = cv2.imread(IMG_NAME, cv2.IMREAD_COLOR)
解决:图片错误(位置、文件名等)
IMG_NAME = "./Test/Set5/butterfly_GT.bmp"