def test_gaussian_noise_disable_training_state(self): test_input = np.ones((50, 20)) gauss_noise = layers.GaussianNoise(std=1) with gauss_noise.disable_training_state(): layer_output = gauss_noise.output(test_input) np.testing.assert_array_equal(layer_output, test_input)
def test_gaussian_noise_repr(self): layer = layers.GaussianNoise(0, 1) self.assertEqual("GaussianNoise(mean=0, std=1)", str(layer))
def test_gaussian_noise_layer(self): test_input = np.zeros((50, 20)) gauss_noise = layers.GaussianNoise(std=0.5) layer_output = self.eval(gauss_noise.output(test_input)) self.assertTrue(stats.mstats.normaltest(layer_output))
for (left_ax, right_ax), real_image, predicted_image in iterator: real_image = real_image.reshape((28, 28)) predicted_image = predicted_image.reshape((28, 28)) left_ax.imshow(real_image, cmap=plt.cm.binary) right_ax.imshow(predicted_image, cmap=plt.cm.binary) plt.show() if __name__ == '__main__': autoencoder = algorithms.Momentum( [ layers.Input(784), layers.GaussianNoise(mean=0.5, std=0.1), layers.Sigmoid(100), layers.Sigmoid(784), ], step=0.1, verbose=True, momentum=0.9, nesterov=True, loss='rmse', ) print("Preparing data...") x_train, x_test = load_data() print("Training autoencoder...") autoencoder.train(x_train, x_train, x_test, x_test, epochs=40)