简体   繁体   English

Numpy 抛出 TypeError: cannot unpack non-iterable NoneType object

[英]Numpy throwing TypeError: cannot unpack non-iterable NoneType object

I have code directly copy pasted from https://blog.varunajayasiri.com/numpy_lstm.html .我有代码直接从https://blog.varunajayasiri.com/numpy_lstm.html复制粘贴。 The code fails on line 195, or:代码在第 195 行失败,或者:

for t in reversed(range(len(inputs))):
    y_val = y_s[t]
    # Backward pass
    dh_next, dC_next = \
        backward(target = targets[t], dh_next = dh_next,
                 dC_next = dC_next, C_prev = C_s[t-1],
                 z = z_s[t], f = f_s[t], i = i_s[t], C_bar = C_bar_s[t],
                 C = C_s[t], o = o_s[t], h = h_s[t], v = v_s[t],
                 y = y_val)

I manually set y_val so I could check the value, and when checking right before the crash, it clearly prints a numpy array, but when it gets to backward , it crashed.我手动设置y_val以便检查该值,并且在崩溃前检查时,它清楚地打印了一个backward数组,但是当它返回时,它崩溃了。 Changing y to anything else, say as an example:y更改为其他任何内容,例如:

backward(target = targets[t], dh_next = dh_next,
                     dC_next = dC_next, C_prev = C_s[t-1],
                     z = z_s[t], f = f_s[t], i = i_s[t], C_bar = C_bar_s[t],
                     C = C_s[t], o = o_s[t], h = h_s[t], v = v_s[t],
                     y = 4)

And the code runs perfectly fine (only crashing due to an assertion error inside the function due to shape mismatch).并且代码运行得非常好(仅由于形状不匹配导致 function 内部的断言错误而崩溃)。 It also runs fine if I set it to some random numpy array:如果我将它设置为一些随机的 numpy 数组,它也运行良好:

backward(target = targets[t], dh_next = dh_next,
                     dC_next = dC_next, C_prev = C_s[t-1],
                     z = z_s[t], f = f_s[t], i = i_s[t], C_bar = C_bar_s[t],
                     C = C_s[t], o = o_s[t], h = h_s[t], v = v_s[t],
                     y = np.array[1,2,3,4,5,6,7,8,9])

Again only crashes due to the assertion error.再次只是由于断言错误而崩溃。

Does anyone know what's going on here?有谁知道这里发生了什么? I am very confused.我很困扰。

Here's the full error:这是完整的错误:

data has 43 characters, 28 unique
Traceback (most recent call last):
  File "C:\Users\a\Desktop\stuff\b\lstm\example_lstm.py", line 287, in <module>
    forward_backward(inputs, targets, g_h_prev, g_C_prev)
  File "C:\Users\a\Desktop\stuff\b\lstm\example_lstm.py", line 195, in forward_backward
    y = y_val)
TypeError: cannot unpack non-iterable NoneType object

It was a problem with the traceback.这是回溯的问题。 Turns out it was actually getting inside the function, and then throwing an error on a for loop inside the function, but for some reason wasn't giving any indication that is is where it was crashing.原来它实际上进入了 function 内部,然后在 function 内部的 for 循环上抛出了一个错误,但由于某种原因,它没有给出任何迹象表明它在哪里崩溃。 Very strange, maybe it's a bug to do with non-iterable TypeError's?很奇怪,也许这是与不可迭代的TypeError有关的错误? Not sure, none-the-less that's what was going on.不确定,不过这就是发生了什么。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PyAutoGui TypeError:无法解压不可迭代的NoneType object - PyAutoGui TypeError: cannot unpack non-iterable NoneType object -- TypeError: cannot unpack non-iterable NoneType object - -- TypeError: cannot unpack non-iterable NoneType object 方法 Euler TypeError: cannot unpack non-iterable NoneType object - Method Euler TypeError: cannot unpack non-iterable NoneType object TypeError:无法解压不可迭代的 NoneType 对象 - TypeError: cannot unpack non-iterable NoneType object TypeError:无法解压不可迭代的 NoneType 对象错误 - TypeError: cannot unpack non-iterable NoneType object Error Pyautogui Image 工作一段时间后不可迭代,TypeError: cannot unpack non-iterable NoneType object - Pyautogui Image non-iterable after working for a while, TypeError: cannot unpack non-iterable NoneType object 类型错误:无法解压不可迭代的 object - TypeError: cannot unpack non-iterable object TypeError: cannot unpack non-iterable NoneType object: 找不到我的数据变成“无类型”的位置 - TypeError: cannot unpack non-iterable NoneType object: Cannot find where my data turned into “None Type” 我得到:TypeError: cannot unpack non-iterable NoneType object,但我正在返回一个元组 - I am getting: TypeError: cannot unpack non-iterable NoneType object, but I am returning a tuple "有人可以向我解释为什么 pyautogui TypeError: cannot unpack non-iterable NoneType object" - Can someone explain to me why pyautogui TypeError: cannot unpack non-iterable NoneType object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM