예제 #1
0
    def recall_for_i_iters(self, should_display_image, num_of_iterations):
        rand_in = Tools.get_random_input(49)
        self.setup_input(rand_in)
        for i in range(num_of_iterations):
            # Attempt to set a random input for every iteration:
            self.recall()
            if should_display_image:
                Tools.show_image_from(out_now=self.output_values.get_value())

        # print "Returning from chaotic recall after", num_of_iterations, "iterations."
        return [rand_in, self.output_values.get_value()]
예제 #2
0
    def recall_until_stability_criteria(self, should_display_image, max_iterations):
        # recall until output unchanged three iterations
        out_now = np.copy(self.output_values.get_value())
        out_min_1 = np.zeros_like(out_now, dtype=np.float32)
        found_stable_output = False
        ctr = 0
        while not found_stable_output and ctr < max_iterations:
            out_min_2 = np.copy(out_min_1)
            out_min_1 = np.copy(out_now)

            # Attempt to set a random input for every iteration:
            self.recall()
            out_now = np.copy(self.output_values.get_value())
            found_stable_output = True
            for out_y in xrange(out_now.shape[1]):
                if not (out_min_2[0][out_y] == out_min_1[0][out_y] == out_now[0][out_y]):
                    found_stable_output = False
                    break
            ctr += 1
        if should_display_image and found_stable_output:
            Tools.show_image_from(out_now=out_now)

        print "Reached stability or max. #iterations during chaotic recall after", ctr, "iterations."
        return [ctr, found_stable_output, out_now]