Skip to content

Commit 71dffef

Browse files
authored
Merge branch 'master' into kernelfix
2 parents 146fac6 + a06b381 commit 71dffef

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

beginner_source/dcgan_faces_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
# :math:`D` and :math:`G` play a minimax game in which :math:`D` tries to
7272
# maximize the probability it correctly classifies reals and fakes
7373
# (:math:`logD(x)`), and :math:`G` tries to minimize the probability that
74-
# :math:`D` will predict its outputs are fake (:math:`log(1-D(G(x)))`).
74+
# :math:`D` will predict its outputs are fake (:math:`log(1-D(G(z)))`).
7575
# From the paper, the GAN loss function is
7676
#
7777
# .. math:: \underset{G}{\text{min}} \underset{D}{\text{max}}V(D,G) = \mathbb{E}_{x\sim p_{data}(x)}\big[logD(x)\big] + \mathbb{E}_{z\sim p_{z}(z)}\big[log(1-D(G(z)))\big]

intermediate_source/reinforcement_q_learning.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
import numpy as np
6464
import matplotlib
6565
import matplotlib.pyplot as plt
66-
from collections import namedtuple
66+
from collections import namedtuple, deque
6767
from itertools import count
6868
from PIL import Image
6969

@@ -115,16 +115,11 @@
115115
class ReplayMemory(object):
116116

117117
def __init__(self, capacity):
118-
self.capacity = capacity
119-
self.memory = []
120-
self.position = 0
118+
self.memory = deque([],maxlen=capacity)
121119

122120
def push(self, *args):
123-
"""Saves a transition."""
124-
if len(self.memory) < self.capacity:
125-
self.memory.append(None)
126-
self.memory[self.position] = Transition(*args)
127-
self.position = (self.position + 1) % self.capacity
121+
"""Save a transition"""
122+
self.memory.append(Transition(*args))
128123

129124
def sample(self, batch_size):
130125
return random.sample(self.memory, batch_size)

0 commit comments

Comments
 (0)