【问题标题】:python RuntimeWarning: invalid value encountered in subtract x = asanyarray(arr - arrmean)python RuntimeWarning:在减去 x = asanyarray(arr - arrmean) 中遇到无效值
【发布时间】:2020-06-14 07:51:33
【问题描述】:

我最近刚刚掌握了深度学习的窍门,我想尝试运行 this 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):

Patience 设置得太 100,所以每 100 个 epoch 后它会提前停止并重新启动。我的印象是这不正常,但我不确定如何解决这个问题。任何帮助,将不胜感激!

【问题讨论】:

    标签: python numpy deep-learning conv-neural-network


    【解决方案1】:

    如果不查看更多代码或数据本身,很难说出发生了什么,但在对无效数据(例如无穷大或非数字 (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

    【讨论】:

      猜你喜欢
      • 2019-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-13
      • 2013-01-29
      • 1970-01-01
      • 2021-02-07
      • 1970-01-01
      相关资源
      最近更新 更多