I have the following Python 2 code which unpacks a tuple inside a lambda. This lambda is contained inside a for loop.
for lab, lab_pred, length in zip(labels, labels_pred, sequence_lengths):
accs += map(lambda (a, b): a == b, zip(lab, lab_pred))
What is the best way to port this into Python 3?
I think the best solution would be to not use map and lambda, use a list comprehension instead:
accs += [a == b for a, b in zip(lab, lab_pred)]
If you prefer functional style there is:
from operator import eq
from itertools import starmap
accs.extend(starmap(eq, zip(lab, lab_pred)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With