I am trying to understand the Deep Q-learning algorithm for standard Cart-pole example using this tutorial, and in def optimize_model() method, I don't understand whether the lambda expression returns a boolean or an index:
non_final_mask = torch.tensor(tuple(map(lambda s: s is not None, batch.next_state)), device=device, dtype=torch.bool)
where batch.next_state
is just a list, and s
is defined only in this line.
Judging from the documentation and this example, lambda s: s is not None
produces a boolean. However, when I simply type in python:
>>> lambda s: s is None
I get
<function <lambda> at 0x100997010>
If I indeed get a boolean from aforementioned lambda expression, how does the map()
method handels it as a first argument?
Thanks for any help in advance.
EDIT: Thank you very much for all your comments and thorough answers! I need a little time to chew it all, but I disagree with [duplicate] mark, as I haven't seen anywhere how boolean function have been applied to a list with map()
. It is still not that clear to me.