def _random_overlay(self, static_hidden=False):
"""Construct random max pool locations."""
s = self.shapes[2]
if static_hidden:
args = np.random.randint(s[2], size=np.prod(s) / s[2] / s[4])
overlay = np.zeros(np.prod(s) / s[4], np.bool)
overlay[args + np.arange(len(args)) * s[2]] = True
overlay = overlay.reshape([s[0], s[1], s[3], s[2]])
overlay = np.rollaxis(overlay, -1, 2)
return arrays.extend(overlay, s[4])
else:
args = np.random.randint(s[2], size=np.prod(s) / s[2])
overlay = np.zeros(np.prod(s), np.bool)
overlay[args + np.arange(len(args)) * s[2]] = True
overlay = overlay.reshape([s[0], s[1], s[3], s[4], s[2]])
return np.rollaxis(overlay, -1, 2)
评论列表
文章目录