def forward(self, inputtensor):
inputimage = inputtensor[0]
if self.dc == 0.0:
pass
else:
if 0 <self.dc <=1:
_srng = RandomStreams(np.random.randint(1, 2147462579))
one = T.constant(1)
retain_prob = one - self.dc
mask_shape = self.w.shape
mask = _srng.binomial(mask_shape, p=retain_prob,
dtype=self.w.dtype)
self.w = self.w * mask
else:
raise IndexError
if self.need_bias:
return ((T.dot(inputimage, self.w)+self.b), )
else:
return (T.dot(inputimage, self.w),)
评论列表
文章目录