python调试程序中遇到的不常见bug汇总

在调试程序中,除了一些常见的语法错误,也有各种各样的安装包的兼容性问题。此博客也将不断进行更新!

Bug 1

运行文件出现如下错误:

Unable to open '_objects.pyx': File not found

初步怀疑是import h5py时出错,查看安装包时发现已经安装了h5py包,查找资料有人在安装TensorFlow时也出现过类似问题,其中的一个包prtobuf版本不兼容问题,更改版本为3.6.0即可,然后还是出现同样的错误。

#查看安装清单

最后重新利用conda重新安装了h5py,系统自动安装了其他的几个包,亲测可用,程序运行没问题了。

Bug 2:

出现警告的源代码段:

cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=Z3, labels=Y))

WARNING:tensorflow:From e:\吴恩达深度学习笔记\编程练习\Convolution model.py:163: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

故障原因函数升级引起的兼容性问题,根据提示,更改如下:

cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(logits=Z3, labels=Y))

Bug 3:...

猜你喜欢

转载自blog.csdn.net/qq_41997920/article/details/88352746