Closed Hofer-Julian closed 1 year ago
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
The issue is with map being a generator/iterator that you can use only once
>>> m = map(lambda x:x*10, [1,2,3])
>>> a,b,c = m
>>> test = m
>>> a, b, c
(10, 20, 30)
>>> test
<map object at 0x1046689a0>
>>> list(test)
[]
you can solve this by adding tuple in front of map
>>> test = a,b,c = tuple(map(str, [1,2,3]))
>>> test
('1', '2', '3')
>>> a, b, c
('1', '2', '3')
But it is good catch, the double assignment is indeed quite problematic, as it doesn't work for some getitem implementations.
you can simplify the code a bit by saving to grads first, like so
ptgrads = w12,w22,b12,b22,xt2 = map(mkgrad, chks)
becomes:
ptgrads = tuple(map(mkgrad, chks))
w12,w22,b12,b22,xt2 = ptgrads
Many thanks! I'll update it to the tuple
version.
Double assignment seems to do something different than expected in Python Changing it to two statements fixes it. This also reveals that the
grad
property is accessed at the wrong value.