【发布时间】:2020-02-21 23:22:19
【问题描述】:
我刚得到一个 RTX 2070 Super,我想尝试使用带有 TensorFlow 后端的 Keras 进行半精度训练。
到目前为止,我发现了类似 this one 的文章建议使用此设置:
import keras.backend as K
dtype='float16'
K.set_floatx(dtype)
# default is 1e-7 which is too small for float16. Without adjusting the epsilon, we will get NaN predictions because of divide by zero problems
K.set_epsilon(1e-4)
该网络是用于音频分类的简单 4 层 CNN。
我的输入数据是之前生成的 NumPy 3D 数组(使用 LibROSA 提取的音频 MFCC 特征)。此数据是使用 CPU 生成的,我知道这些值保存为 32 位浮点数。
当我尝试使用这些数据训练我的网络时,我收到以下错误:
TypeError:传递给“合并”操作的“输入”的列表中的张量具有不完全匹配的类型 [float16, float32]。
在另一篇文章中,我读到我还应该“在 SoftMax 层之前回退到 FP32”,这让事情变得更加令人困惑......
我真的很感激一些指导。
谢谢!
【问题讨论】:
标签: tensorflow keras rtx half-precision-float