def test_mixed_parallel_flow(self):
     """Test a ParallelBiFlow with both standard and BiNodes."""
     flow = ParallelBiFlow([mdp.nodes.PCANode(output_dim=8), SFABiNode(output_dim=5), SFA2BiNode(output_dim=20)])
     data_iterables = [[n.random.random((20, 10)) for _ in range(6)]] * 3
     scheduler = mdp.parallel.Scheduler()
     flow.train(data_iterables, scheduler=scheduler)
     x = n.random.random([100, 10])
     flow.execute(x)
     iterator = [n.random.random((20, 10)) for _ in range(6)]
     flow.execute(iterator, scheduler=scheduler)
     scheduler.shutdown()
Exemplo n.º 2
0
 def test_use_copies_msg(self):
     """Test the correct reaction to an outgoing use_copies message."""
     stop_result = ({"clonelayer" + MSG_ID_SEP + "use_copies": True},
                    EXIT_TARGET)
     stop_sfa_node = SFABiNode(stop_result=stop_result,
                               input_dim=10, output_dim=3)
     biflownode = BiFlowNode(BiFlow([stop_sfa_node]))
     clonelayer = ParallelCloneBiLayer(node=biflownode,
                                             n_nodes=3,
                                             use_copies=False,
                                             node_id="clonelayer")
     data = [[n.random.random((100,30)) for _ in range(5)]]
     biflow = ParallelBiFlow([clonelayer])
     biflow.train(data, scheduler=mdp.parallel.Scheduler())
     assert clonelayer.use_copies is True
Exemplo n.º 3
0
 def test_mixed_parallel_flow(self):
     """Test a ParallelBiFlow with both standard and BiNodes."""
     flow = ParallelBiFlow([
         mdp.nodes.PCANode(output_dim=8),
         SFABiNode(output_dim=5),
         SFA2BiNode(output_dim=20)
     ])
     data_iterables = [[n.random.random((20, 10)) for _ in range(6)]] * 3
     scheduler = mdp.parallel.Scheduler()
     flow.train(data_iterables, scheduler=scheduler)
     x = n.random.random([100, 10])
     flow.execute(x)
     iterator = [n.random.random((20, 10)) for _ in range(6)]
     flow.execute(iterator, scheduler=scheduler)
     scheduler.shutdown()
Exemplo n.º 4
0
 def test_nonparallel_flow(self):
     """Test a ParallelBiFlow with standard nodes."""
     flow = ParallelBiFlow([mdp.nodes.SFANode(output_dim=5),
                            mdp.nodes.PolynomialExpansionNode(degree=3),
                            mdp.nodes.SFANode(output_dim=20)])
     data_iterables = [[n.random.random((20,10)) for _ in range(6)],
                       None,
                       [n.random.random((20,10)) for _ in range(6)]]
     scheduler = mdp.parallel.Scheduler()
     flow.train(data_iterables, scheduler=scheduler)
     x = n.random.random([100,10])
     flow.execute(x)
     iterator = [n.random.random((20,10)) for _ in range(6)]
     flow.execute(iterator, scheduler=scheduler)
     scheduler.shutdown()
Exemplo n.º 5
0
 def test_nonparallel_flow(self):
     """Test a ParallelBiFlow with standard nodes."""
     flow = ParallelBiFlow([
         mdp.nodes.SFANode(output_dim=5),
         mdp.nodes.PolynomialExpansionNode(degree=3),
         mdp.nodes.SFANode(output_dim=20)
     ])
     data_iterables = [[n.random.random((20, 10)) for _ in range(6)], None,
                       [n.random.random((20, 10)) for _ in range(6)]]
     scheduler = mdp.parallel.Scheduler()
     flow.train(data_iterables, scheduler=scheduler)
     x = n.random.random([100, 10])
     flow.execute(x)
     iterator = [n.random.random((20, 10)) for _ in range(6)]
     flow.execute(iterator, scheduler=scheduler)
     scheduler.shutdown()
Exemplo n.º 6
0
 def test_use_copies_msg(self):
     """Test the correct reaction to an outgoing use_copies message."""
     stop_result = ({
         "clonelayer" + MSG_ID_SEP + "use_copies": True
     }, EXIT_TARGET)
     stop_sfa_node = SFABiNode(stop_result=stop_result,
                               input_dim=10,
                               output_dim=3)
     biflownode = BiFlowNode(BiFlow([stop_sfa_node]))
     clonelayer = ParallelCloneBiLayer(node=biflownode,
                                       n_nodes=3,
                                       use_copies=False,
                                       node_id="clonelayer")
     data = [[n.random.random((100, 30)) for _ in range(5)]]
     biflow = ParallelBiFlow([clonelayer])
     biflow.train(data, scheduler=mdp.parallel.Scheduler())
     assert clonelayer.use_copies is True
    def test_parallel_process(self):
        """Test training and execution with multiple training phases.

        The node with multiple training phases is a hinet.FlowNode.
        """
        sfa_node = mdp.nodes.SFANode(input_dim=10, output_dim=8)
        sfa2_node = mdp.nodes.SFA2Node(input_dim=8, output_dim=6)
        flow = ParallelBiFlow([sfa_node, sfa2_node])
        data_iterables = [[n.random.random((30, 10)) for _ in range(6)], [n.random.random((30, 10)) for _ in range(7)]]
        scheduler = mdp.parallel.ProcessScheduler(n_processes=2)
        flow.train(data_iterables, scheduler=scheduler)
        flow.execute(data_iterables[1], scheduler=scheduler)
        x = n.random.random([100, 10])
        flow.execute(x)
        iterator = [n.random.random((20, 10)) for _ in range(6)]
        flow.execute(iterator, scheduler=scheduler)
        scheduler.shutdown()
Exemplo n.º 8
0
    def test_parallel_process(self):
        """Test training and execution with multiple training phases.

        The node with multiple training phases is a hinet.FlowNode.
        """
        sfa_node = mdp.nodes.SFANode(input_dim=10, output_dim=8)
        sfa2_node = mdp.nodes.SFA2Node(input_dim=8, output_dim=6)
        flow = ParallelBiFlow([sfa_node, sfa2_node])
        data_iterables = [[n.random.random((30, 10)) for _ in range(6)],
                          [n.random.random((30, 10)) for _ in range(7)]]
        scheduler = mdp.parallel.ProcessScheduler(n_processes=2)
        flow.train(data_iterables, scheduler=scheduler)
        flow.execute(data_iterables[1], scheduler=scheduler)
        x = n.random.random([100, 10])
        flow.execute(x)
        iterator = [n.random.random((20, 10)) for _ in range(6)]
        flow.execute(iterator, scheduler=scheduler)
        scheduler.shutdown()