def test_visualizations(self): # test that visualization doesn't error in grayscale and RGB settings (x_train, _), (_, _), (_, _) = self.mnist self.defence.visualize_clusters(x_train) x_train_rgb = convert_to_rgb(x_train) self.defence.visualize_clusters(x_train_rgb)
def test_convert_gray_to_rgb(self): # Get MNIST (x, _), (_, _), _, _ = load_mnist(raw=True) n = 100 x = x[:n] # Test RGB x_rgb = convert_to_rgb(x) s_original = np.shape(x) s_new = np.shape(x_rgb) self.assertEqual(s_new[0], s_original[0]) self.assertEqual(s_new[1], s_original[1]) self.assertEqual(s_new[2], s_original[2]) self.assertEqual(s_new[3], 3) # Should have added 3 channels