tf2报错解决 assertion failed: [predictions must be >= 0] [Condition x >= y did not hold element-wise:]
环境: tf2完整报错如下:tensorflow.python.framework.errors_impl.InvalidArgumentError:assertion failed: [predictions must be >= 0] [Condition x >= y did not hold element-wise:] [x (sub_2:0) = ] [[-nan][-na
·
环境: tf2
完整报错如下:
tensorflow.python.framework.errors_impl.InvalidArgumentError: assertion failed: [predictions must be >= 0] [Condition x >= y did not hold element-wise:] [x (sub_2:0) = ] [[-nan][-nan][-nan]...] [y (Cast_2/x:0) = ] [0]
[[{{node assert_greater_equal/Assert/AssertGuard/else/_1/assert_greater_equal/Assert/AssertGuard/Assert}}]] [Op:__inference_train_function_1780]
解决方法:
- 检查模型最后一层,是否忘记添加激活函数softmax
layers.Dense(number_of_tags, activation='softmax', name='decoder_dense')
- 检查是否调用了sqrt这类的函数,并要确保目标不为零
tf.sqrt(xxx+tf.keras.backend.epsilon)
- 检查learning rate是否过大,导致nan
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献2条内容
所有评论(0)