Closed StrangeTcy closed 5 years ago
Hi!
You're right, your version is better and has the same semantics. Don't remember why I used map and list :)
пт, 23 авг. 2019 г., 17:07 Maxim Smirnov notifications@github.com:
Is there any specific reason you're not using list comprehensions? It seems much more "pythonic" than dealing with lists, maps and lambdas. For example, in corssentropy_cartpole https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On/blob/master/Chapter04/01_cartpole.py you're getting rewards from a batch like this:
def filter_batch(batch, percentile): rewards = list(map(lambda s: s.reward, batch))
while the same could be written as
def filter_batch(batch, percentile): rewards = [s.reward for s in batch]
,which (to me, anyway) looks cleaner and easier to understand.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On/issues/56?email_source=notifications&email_token=AAAQE2RMAWORQ2LYYOX4ZYLQF7VLFA5CNFSM4IPAA7H2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HHBUT5Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAQE2U77SLWPC5NAH6JANTQF7VLFANCNFSM4IPAA7HQ .
Ok then :-)
Is there any specific reason you're not using list comprehensions? It seems much more "pythonic" than dealing with lists, maps and lambdas. For example, in crossentropy_cartpole you're getting rewards from a batch like this:
while the same could be written as
,which (to me, anyway) looks cleaner and easier to understand.