示例#1
0
    def predict(self, num_iterations: int) -> Results:
        # TODO "method" rst
        # TODO replace num_activation by proper test
        """

        Parameters
        ----------
        num_iterations : int
            Discrete number of prediction iteration steps to perform by :method:predict method

        Returns
        -------
        Results
            Object containing results from all predication iterations.

        """
        global num_activations
        num_activations = 0
        result = Results()
        self.adjacency.transposed()
        self.newly_activated_ = np.where(self.state_matrix_.matrix)
        for l in range(num_iterations):
            result.add_result(self.__single_iteration())
        # print(num_activations)
        return result
示例#2
0
def save_results(result: Results, dir, num_predictions):
    for iter in range(num_predictions):
        matrix = result.get_result(iter).matrix
        file_name = dir + '/result_' + str(iter) + '.pickle'
        os.makedirs(os.path.dirname(file_name), exist_ok=True)
        with open(file_name, 'wb') as file:
            pickle.dump(matrix, file)
示例#3
0
def save_results(result: Results, dir, num_predictions):
    for iter in range(num_predictions):
        matrix = result.get_result(iter).matrix
        file_name = dir + 'result_' + str(iter) + '.pickle'
        with open(file_name, 'wb') as file:
            pickle.dump(matrix, file)