简述isNaN()和NaN的区别

本文深入探讨了isNaN()函数的工作原理,解释了如何使用它来检查一个值是否为非数字。同时,文章还讨论了NaN的特性,包括为什么NaN不等于自身。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

isNaN() 是一个全局方法,它的作用是检查一个值是否是非数字,不是数字就返回true,是数字就返回false。

当一个字符串不能被 Number、parseInt 或 parseFloat 成功转换时,就返回 NaN,表示该字符串无法被识别为数字类型,这是一个异常状态,并不是一个确切的值。
注意:NaN不等于NaN。

/home/wfs/anaconda3/envs/open-mmlab/lib/python3.8/site-packages/torch/nn/functional.py:3981: UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details. warnings.warn( /home/wfs/anaconda3/envs/open-mmlab/lib/python3.8/site-packages/mmcv/runner/hooks/optimizer.py:31: FutureWarning: Non-finite norm encountered in torch.nn.utils.clip_grad_norm_; continuing anyway. Note that the default behavior will change in a future release to error out if a non-finite total norm is encountered. At that point, setting error_if_nonfinite=false will be required to retain the old behavior. return clip_grad.clip_grad_norm_(params, **self.grad_clip) 2025-07-25 20:01:14,499 - mmcv - INFO - Reducer buckets have been rebuilt in this iteration. 2025-07-25 20:01:56,509 - mmdet - INFO - Epoch [1][50/28130] lr: 3.987e-05, eta: 8 days, 10:31:11, time: 0.926, data_time: 0.079, memory: 4884, loss_cls: 2.1964, loss_bbox: 2.3503, d0.loss_cls: 2.2795, d0.loss_bbox: 2.3152, loss: 9.1414, grad_norm: nan 2025-07-25 20:02:39,278 - mmdet - INFO - Epoch [1][100/28130] lr: 4.653e-05, eta: 8 days, 2:48:52, time: 0.855, data_time: 0.015, memory: 4884, loss_cls: 2.2189, loss_bbox: 2.3256, d0.loss_cls: 2.2865, d0.loss_bbox: 2.2834, loss: 9.1145, grad_norm: nan 2025-07-25 20:03:22,356 - mmdet - INFO - Epoch [1][150/28130] lr: 5.320e-05, eta: 8 days, 0:41:24, time: 0.862, data_time: 0.015, memory: 4884, loss_cls: 2.2252, loss_bbox: 2.2780, d0.loss_cls: 2.2865, d0.loss_bbox: 2.2274, loss: 9.0171, grad_norm: nan
最新发布
07-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值