首页 > 解决方案 > 使用混合精度和构建 EfficientNetB0 模型时出现 Dtype 错误

问题描述

系统信息

错误 TypeError: Input 'y' of 'Sub' Op has type float16 that does not match type float32 of argument 'x'

当前行为

在使用混合精度并构建 Keras 功能 API 模型 (EfficientNet B0) 时,它显示以下错误 TypeError: Input 'y' of 'Sub' Op has type float16 that does not match type float32 of argument 'x'

注意:由于某种原因 StackOverflow 不允许我发布图片。访问以下链接以更深入地了解该问题: https ://github.com/tensorflow/tensorflow/issues/49725

预期行为

我在上一个单元格中设置的全局策略是mixed_float16. 运行时问题正常,tensorflow 2.4.1因此错误与tensorflow 2.5.0

您可以使用以下笔记本重现相同的错误: https ://colab.research.google.com/drive/1TfNZSIJ_I7IZI35RsGFnTdj-6beMHV2_?usp=sharing

标签: pythontensorflowtensorflow2.0efficientnetautomatic-mixed-precision

解决方案


推荐阅读