示例#1
0
    def __init__(self, n_inputs=4, n_agents=2, n_outputs=1):
        """
        Initializes the network, including random connection strengths.
        """
        # Defines the connection structure: half of incoming signals connect to one processing agent, half to the other.
        # Both processing agents connect to the one final output node
        split_pt = n_inputs / n_agents
        self.connections = [[i, n_inputs + 1 * (split_pt > i)]
                            for i in range(n_inputs)]
        self.connections.extend([[i, n_inputs + n_agents]
                                 for i in range(n_inputs, n_inputs + n_agents)
                                 ])
        self.n_inputs = n_inputs
        self.n_agents = n_agents

        #  Creates agents based on this connection structure
        self.agents = [agents.InputAgent(agent_id=i) for i in range(n_inputs)]
        self.agents.extend([
            agents.LinearSRS(agent_id=n_inputs + i,
                             n_connections_in=1 +
                             np.sum(np.asarray(self.connections)[:, 1] == i))
            for i in range(n_agents)
        ])
        self.agents.extend([
            agents.LinearSRS(agent_id=n_inputs + n_agents + i,
                             n_connections_in=1 + n_agents)
            for i in range(n_outputs)
        ])
示例#2
0
    def __init__(self,
                 error_function=None,
                 n_inputs=4,
                 n_agents=2,
                 n_outputs=1):
        """
        Initializes the network, including random connection strengths.
        """
        super().__init__(error_function, n_agents)
        # Defines the connection structure: half of incoming signals connect to one processing agent, half to the other.
        # Both processing agents connect to the one final output node
        split_pt = n_inputs / n_agents
        self.connections = [[i, n_agents] for i in range(n_agents)]
        self.n_inputs = n_inputs
        self.n_agents = n_agents

        #  Creates agents based on this connection structure
        self.agents = [
            agents.LinearSRS(agent_id=i,
                             n_connections_in=1 +
                             np.sum(np.asarray(self.connections)[:, 1] == i))
            for i in range(n_agents + n_inputs)
        ]
        self.agents.extend([
            agents.LinearSRS(agent_id=n_inputs + n_agents + i,
                             n_connections_in=1 + n_agents)
            for i in range(n_outputs)
        ])

        # Logs the error function for this network
        self.error_function = error_function
示例#3
0
    def __init__(self,
                 error_function=None,
                 n_inputs=5,
                 n_agents=5,
                 n_outputs=1):
        """
        Initializes the network as fully connected: each agent receives input from all inputs and all other previous agents.
        """
        super().__init__(error_function, n_agents)
        # Defines the connection structure: half of incoming signals connect to one processing agent, half to the other.
        # Both processing agents connect to the one final output node
        split_pt = n_inputs / n_agents
        self.connections = [[i, n_inputs + 1] for i in range(n_inputs)]
        self.connections.extend([[i, i + 1]
                                 for i in range(n_inputs, n_inputs + n_agents)
                                 ])
        self.connections.extend(
            [[n_inputs + n_agents - 1, n_inputs + n_agents + n_outputs - 1]])
        self.n_inputs = n_inputs
        self.n_agents = n_agents

        #  Creates agents based on this connection structure
        self.agents = [agents.InputAgent(agent_id=i) for i in range(n_inputs)]
        self.agents.extend([
            agents.LinearSRS(agent_id=n_inputs + i,
                             n_connections_in=1 + (n_inputs - 1) *
                             (i == n_inputs))
            for i in range(n_agents + n_outputs)
        ])
示例#4
0
    def __init__(self,
                 error_function=error_propagation.propagate_signal_importance,
                 n_inputs=4,
                 n_agents=2,
                 n_outputs=1):
        """
        Initializes the network.
        """
        super().__init__(error_function, n_agents)
        self.n_inputs = n_inputs
        self.n_agents = n_agents

        # Sets up the input agent connections: all input agents send information to all processing agents
        self.connections = []
        for processing_agent in range(n_agents):
            self.connections.extend([[i, n_inputs + processing_agent]
                                     for i in range(n_inputs)])

        for output_agent in range(n_outputs):
            self.connections.extend(
                [[n_inputs + i, n_inputs + n_agents + output_agent]
                 for i in range(n_agents)])

        #  Creates input + processing units that are RELUs and output agents that are Linear
        self.agents = [
            agents.ReLUSRS(agent_id=i,
                           n_connections_in=1 +
                           np.sum(np.asarray(self.connections)[:, 1] == i))
            for i in range(n_agents + n_inputs)
        ]
        self.agents.extend([
            agents.LinearSRS(agent_id=n_inputs + n_agents + i,
                             n_connections_in=1 + n_agents)
            for i in range(n_outputs)
        ])
示例#5
0
    def __init__(self,
                 error_function=error_propagation.propagate_signal_importance,
                 n_inputs=4,
                 n_agents=2,
                 n_outputs=1):
        """
        Initializes the network, including random connection strengths.
        """
        super().__init__(error_function, n_agents)
        # Defines the connection structure: half of incoming signals connect to one processing agent, half to the other.
        # Both processing agents connect to the one final output node
        split_pt = n_inputs / n_agents
        self.connections = [[i, n_agents] for i in range(n_agents)]
        self.n_inputs = n_inputs
        self.n_agents = n_agents

        #  Creates input + processing units that are RELUs and output agents that are Linear
        self.agents = [
            agents.ReLUSRS(agent_id=i,
                           n_connections_in=1 +
                           np.sum(np.asarray(self.connections)[:, 1] == i))
            for i in range(n_agents + n_inputs)
        ]
        self.agents.extend([
            agents.LinearSRS(agent_id=n_inputs + n_agents + i,
                             n_connections_in=1 + n_agents)
            for i in range(n_outputs)
        ])
示例#6
0
 def __init__(self, n_agents=1):
     """
     Initializes the network, specifying each agent and which agents connect to one another
     """
     # TODO: Let's build in the definitions of an input node. That'll allow us to experiment with mutliple inputs,
     # TODO: and test whether the errors we're seeing are exclusive to line-line networks.
     self.agents = [
         agents.LinearSRS(agent_id=i, n_connections_in=2)
         for i in range(n_agents)
     ]
     self.connections = [[i, i + 1] for i in range(n_agents - 1)]