def skip_connect(self, input, layer_index):
if ([] == self.noisy_z):
raise ValueError('Error: noisy_z is an empty list, noisy_fprop must be run before skip_connect')
MU = self.compute_mu(input, self.As[layer_index])
V = self.compute_v(input, self.As[layer_index])
reconstruction = (self.noisy_z[-1] - MU) * V + MU
# # Non trainable Batchnormalisation
# mean = reconstruction.mean(0)
# std = reconstruction.std(0) + 1e-10
#
# # Only batchnormalise for a batchsize > 1
# mean = ifelse(T.gt(input.shape[0], 1), mean, T.zeros(mean.shape, dtype=mean.dtype))
# std = ifelse(T.gt(input.shape[0], 1), std, T.ones(std.shape, dtype=std.dtype))
# reconstruction = (reconstruction - mean) / std
self.tmp = reconstruction
# To caluclate the reconstruction error later
self.reconstructions.append(reconstruction)
self.noisy_z = self.noisy_z[0:-1]
return reconstruction
评论列表
文章目录