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))
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)
def get_set(self, network, test): test_in, test_out = test activations = network.get_activation_of_all_layers(test_in) group = Group(*map(MNistMobject, activations)) group.arrange_submobjects(RIGHT, buff=LARGE_BUFF) return group