当前位置:网站首页>Tensorflow踩坑笔记,记录各种报错和解决方法
Tensorflow踩坑笔记,记录各种报错和解决方法
2022-08-05 05:15:00 【takedachia】
不知道是不是错觉,tensorflow比pytorch容易报错,记录一下踩的坑。
随时更新。
文章目录
0 当出现报错,首先把Jupyter notebook代码换成.py文件直接运行
当出现莫名其妙的报错时,如果你当前使用的是Jupyter notebook,先换成.py文件直接运行试试看。
尤其是gpu版本的tensorflow在Jupyter下容易出问题。
1 Loaded runtime CuDNN library: 7.4.1 but source was compiled with: 7.6.0
初始环境:tensorflow2.0(gpu)、CUDA 10.0、Cudnn 7.4.1、Windows 10
训练卷积神经网络(使用Conv2d类时)报错:
Loaded runtime CuDNN library: 7.4.1 but source was compiled with: 7.6.0.
然而官网的 tensorflow2.0(gpu)的环境要求却写了CUDA 10.0、Cudnn 7.4,误导作用明显。
报错直接提示了解决方案,把Cudnn升级到7.6.0即可,升级方法和安装Cudnn方法相同,去官网下载对应的Cudnn版本,覆盖源文件即可。也可以参考下面的参考资料。
参考资料:
版本不匹配||Loaded runtime CuDNN library: 7.4.2 but source was compiled with: 7.6.0. CuDNN library major
2 自定义的模型不能保存
环境:tensorflow2.0(gpu)、CUDA 10.0、Cudnn 7.6.0、Windows 10
使用tf.keras.models.save_model(model, 'path')保存模型时报错:
ValueError: Model <resnet.Resnet object at 0x000001A9E61DBC50> cannot be saved because the input shapes have not been set. Usually, input shapes are automatically determined from calling .fit() or .predict(). To manually set the shapes, call model._set_inputs(inputs).
参考资料:
1.stackoverflow
2.Github: Model cannot be saved because the input shapes have not been set. #39906
我的解决方案:
model初始化后,在build()中指定input_shape后,再写上model.compute_output_shape(input_shape=(None, 32, 32, 3))即可。
可以保存了:
边栏推荐
猜你喜欢

Flink EventTime和Watermarks案例分析
![[Go through 9] Convolution](/img/84/e6d99793aacf10a7b099f60bcaf290.png)
[Go through 9] Convolution

【After a while 6】Machine vision video 【After a while 2 was squeezed out】
![[Go through 10] sklearn usage record](/img/70/60783c7d16000c6e9d753d8db9a330.png)
[Go through 10] sklearn usage record
![[Let's pass 14] A day in the study room](/img/fc/ff4161db8ed13a0c8ef75b066b8eab.png)
[Let's pass 14] A day in the study room
![[Go through 8] Fully Connected Neural Network Video Notes](/img/0a/8b2510b5536621f402982feb0a01ef.png)
[Go through 8] Fully Connected Neural Network Video Notes

NodeJs接收上传文件并自定义保存路径

【NFT开发】设计师无技术基础保姆级开发NFT教程在Opensea上全套开发一个NFT项目+构建Web3网站

轻松接入Azure AD+Oauth2 实现 SSO

第二讲 Linear Model 线性模型
随机推荐
02.01-----The role of parameter reference "&"
What are the characteristics of the interface of the physical layer?What does each contain?
el-pagination左右箭头替换成文字上一页和下一页
如何编写一个优雅的Shell脚本(二)
day7-列表作业(1)
AIDL详解
flink部署操作-flink standalone集群安装部署
【过一下14】自习室的一天
SQL(一) —— 增删改查
周末作业-循环练习题(2)
Convert the paper official seal in the form of a photo into an electronic official seal (no need to download ps)
day9-字符串作业
学习总结week3_2函数进阶
range函数作用
Redux
ES6 新特性:Class 的继承
基于Flink CDC实现实时数据采集(四)-Sink接口实现
实现跨域的几种方式
关于基于若依框架的路由跳转
怎么更改el-table-column的边框线