Esempio n. 1
0
 def show_all_activation_images(self, network, test_data):
     image_samples = Group(*[
         self.get_activation_images(digit, network, test_data)
         for digit in range(10)
     ])
     image_samples.arrange_submobjects_in_grid(n_rows=2, buff=LARGE_BUFF)
     image_samples.scale_to_fit_height(FRAME_HEIGHT - 1)
     self.add(image_samples)
Esempio n. 2
0
 def show_test_input(self, network):
     training_data, validation_data, test_data = load_data_wrapper()
     group = Group(*[
         self.get_set(network, test) for test in test_data[3:20]
         if test[1] in [4, 9]
     ])
     group.arrange_submobjects(DOWN, buff=MED_LARGE_BUFF)
     group.scale_to_fit_height(FRAME_HEIGHT - 1)
     self.play(FadeIn(group))
Esempio n. 3
0
 def show_random_results(self):
     group = Group(*[
         Group(*[
             MNistMobject(a) for a in network.get_activation_of_all_layers(
                 np.random.randn(784, 1))
         ]).arrange_submobjects(RIGHT) for x in range(10)
     ]).arrange_submobjects(DOWN)
     group.scale_to_fit_height(FRAME_HEIGHT - 1)
     self.add(group)
Esempio n. 4
0
 def get_activation_images(self, digit, network, test_data, n_examples=8):
     input_vectors = [data[0] for data in test_data if data[1] == digit]
     activation_iamges = Group(*[
         Group(*[
             MNistMobject(a)
             for a in network.get_activation_of_all_layers(vect)
         ]).arrange_submobjects(RIGHT)
         for vect in input_vectors[:n_examples]
     ]).arrange_submobjects(DOWN)
     activation_iamges.scale_to_fit_height(FRAME_HEIGHT - 1)
     return activation_iamges
Esempio n. 5
0
 def show_maximizing_inputs(self, network):
     training_data, validation_data, test_data = load_data_wrapper()
     layer = 1
     n_neurons = DEFAULT_LAYER_SIZES[layer]
     groups = Group()
     for k in range(n_neurons):
         out = np.zeros(n_neurons)
         out[k] = 1
         in_vect = maximizing_input(network, layer, out)
         new_out = network.get_activation_of_all_layers(in_vect)[layer]
         group = Group(*map(MNistMobject, [in_vect, new_out]))
         group.arrange_submobjects(DOWN + RIGHT, SMALL_BUFF)
         groups.add(group)
     groups.arrange_submobjects_in_grid()
     groups.scale_to_fit_height(FRAME_HEIGHT - 1)
     self.add(groups)