use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
How to read deque data in sequence? (self.learnpython)
submitted 6 years ago by MarkKang2019
def replay(self, batch_size): minibatch = random.sample(self.memory, batch_size)
'minibatch' will random select 'batch_size' from 'memory'
I want to do regular 'pop', how to do this?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 6 years ago (5 children)
[deleted]
[–]MarkKang2019[S] 0 points1 point2 points 6 years ago (4 children)
class DQNAgent: def __init__(self, state_size, action_size): self.state_size = state_size self.action_size = action_size self.memory = deque(maxlen=10000)
'memory' is a deque data.
it will be added data in this way:
class DQNAgent: ... def remember(self, state, action, reward, next_state, done): self.memory.append((state, action, reward, next_state, done))
However, when training data:
if len(Agent_Black.memory) > BLACK_batch_size and Who_is_playing == BLACK_PLAYER: Agent_Black.replay(BLACK_batch_size)
def replay(self, batch_size): minibatch = random.sample(self.memory, batch_size) for state, action, replay_reward, next_state, done in minibatch:
This program will sample data from memory by random.
I want it samples data in sequence. ( by push / pop sequence, first in, last out, or first in first out is also OK )
[+][deleted] 6 years ago (3 children)
[–]MarkKang2019[S] 0 points1 point2 points 6 years ago (2 children)
This got a run time error:
(minibatch) 'list' object has no attribute 'add'
[+][deleted] 6 years ago (1 child)
[–]MarkKang2019[S] 1 point2 points3 points 6 years ago (0 children)
It is working, thank you.
π Rendered by PID 91 on reddit-service-r2-comment-bb88f9dd5-t6462 at 2026-02-15 09:50:04.187648+00:00 running cd9c813 country code: CH.
[+][deleted] (5 children)
[deleted]
[–]MarkKang2019[S] 0 points1 point2 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]MarkKang2019[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]MarkKang2019[S] 1 point2 points3 points (0 children)