python RuntimeWarning:减法中遇到无效值 x = asanyarray(arr - arrmean)

问题描述 投票:0回答:2

我最近刚刚掌握深度学习的窍门,我想尝试运行 这个 CNN 看看它是如何运行的 + 输出。因为这只是为了测试,而且我没有 GPU,所以我使用了非常小的训练集(69 个文件)和验证集(20),并以批量大小 16 运行它。

看起来运行得很好。但是,我在每个时期都会遇到这些错误:

  x = asanyarray(arr - arrmean)
C:\Users\\directional_cnns-master\directional_cnns\normalizer.py:15: RuntimeWarning: invalid value encountered in subtract
  data = data.copy() - mean
C:\Users\\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\_methods.py:117: RuntimeWarning: invalid value encountered in subtract
  x = asanyarray(arr - arrmean)
C:\Users\\directional_cnns-master\directional_cnns\normalizer.py:15: RuntimeWarning: invalid value encountered in subtract
  data = data.copy() - mean
C:\Users\\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\keras\callbacks.py:1234: RuntimeWarning: invalid value encountered in less
  if self.monitor_op(current - self.min_delta, self.best):

耐心设置得太过 100,因此每经过 100 个时期后,它就会提前停止并重新启动。我的印象是这不正常,但我不知道如何解决这个问题。任何帮助,将不胜感激!

python numpy deep-learning conv-neural-network
2个回答
2
投票

如果不查看更多代码或数据本身,很难说出发生了什么,但是当对无效数据(例如无穷大或非数字 (nan))执行操作时,会出现此错误。

您可以使用以下功能轻松检查数据的有效性:

  1. https://numpy.org/doc/stable/reference/ generated/numpy.isfinite.html
  2. https://numpy.org/doc/stable/reference/ generated/numpy.isinf.html
  3. https://numpy.org/doc/stable/reference/ generated/numpy.isnan.html

0
投票

检查南。

我遇到了类似的问题,dropna() 修复了它。

© www.soinside.com 2019 - 2024. All rights reserved.