Пример #1
0
    def test_run_topology_in_ui(self):
        def callback():
            callback.called = True

        callback.called = False
        ObserverSystem.initialized = False
        observer_system = ObserverSystemVoid(None)

        run_topology_with_ui(TopologyStub(callback), max_steps=1, observer_system=observer_system)

        assert callback.called
Пример #2
0
def run_task1_conv():
    bt = SeT1ConvTopologicalGraph()
    run_topology_with_ui(bt)
Пример #3
0
def run_task1():
    bt = SeT1Bt()
    run_topology_with_ui(bt)
Пример #4
0
def run_task0_conv(use_dataset: bool, save_gpu_memory: bool):
    topology = SeT0ConvTopology(use_dataset=use_dataset, save_gpu_memory=save_gpu_memory)
    run_topology_with_ui(topology)
Пример #5
0
def run_task0_convSP(use_dataset: bool):
    topology = SeT0ConvSPTopology(use_dataset=use_dataset)
    run_topology_with_ui(topology)
Пример #6
0
def run_task0_narrow(use_dataset: bool):
    topology = SeT0NarrowHierarchy(use_dataset=use_dataset)
    run_topology_with_ui(topology, create_non_persisting_observer_system())
Пример #7
0
def run_task0(use_dataset: bool):
    bt = SeT0BasicTopology(use_dataset=use_dataset)
    run_topology_with_ui(bt, create_non_persisting_observer_system())
Пример #8
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--model", default="se_dataset_navigation")
    parser.add_argument("--seed", type=int, help="Global random seed.")
    parser.add_argument("--random-seed",
                        action='store_true',
                        help="Use random seed. Overrides the seed argument.")
    args = parser.parse_args()

    # UI persistence storage file - set to None to turn off the persistence
    storage_file = 'observers.yaml'

    if args.random_seed:
        seed = None
    else:
        seed = args.seed if args.seed is not None else 1337

    def topology_factory(key) -> Topology:
        if key == "SP":
            # works
            model = SpatialPoolerTopology()
        elif key == "SPTP":
            # not updated
            model = SpatialTemporalPoolerTopology()
        elif key == "seq":
            # not updated
            model = SequenceTopology()
        elif key == "noise":
            # works
            model = RandomNoiseTopology()
        elif key == "noise_only":
            # works
            model = RandomNoiseOnlyTopology()
        elif key == "random_num":
            # works
            model = RandomNumberTopology()
        elif key == "switch":
            # works
            model = SwitchTopology()
        elif key == "mnist":
            # works
            model = MnistTopology()
        elif key == "mnist_seq":
            # works
            model = SequenceMnistTopology()
        elif key == "SP_hierarchy":
            # works
            model = SpatialPoolerHierarchy()
        elif key == "bouncing_ball":
            # works
            model = BouncingBallTopology()
        elif key == "debug_agent":
            # works (probably)
            model = DebugAgentTopology()
        elif key == "se_ta":
            # WIP
            model = SeToyArchDebugTopology()
        elif key == "expert":
            # works
            model = ExpertTopology()
        elif key == "expert_hierarchy":
            # works
            model = ExpertHierarchyTopology()
        elif key == "se_dataset_navigation":
            model = SEDatasetSPRepresentationTopology()
        elif key == "se_dataset_objects":
            model = SeDatasetObjectsTopology()
        elif key == "grid_world":
            model = GridWorldTopology()
        elif key == "looping":
            model = LoopingTopology()
        elif key == "conv_sp":
            model = ConvSpatialPoolerTopology()
        elif key == "mse":
            model = MseDemoTopology()
        elif key == "actions_grid_world":
            model = TaActionsGridWorldTopology()
        elif key == "rtx_narrow":
            model = Task0NarrowTopology()
        elif key == "sample_collection":
            model = SEDatasetSampleCollectionTopology()
        elif key == "nnet":
            model = NNetTopology()
        elif key == "l3_conv_topology":
            model = L3ConvTopology()
        elif key == "receptive_field":
            model = ReceptiveFieldTopology()
        elif key == "context_test":
            model = ContextTestTopology()
        elif key == "exploration_grid_world":
            model = TaExplorationGridWorldTopology()
        elif key == "bottom_up_attention":
            model = BottomUpAttentionTopology()
        elif key == "lrf_object_detection_topology":
            model = LrfObjectDetectionTopology()
        elif key == "disentangled_world_node_topology":
            model = DisentangledWorldNodeTopology()
        elif key == "net":
            model = NetworkFlockTopology()
        elif key == "goal_directed":
            model = GoalDirectedTopology()
        elif key == "goal_directed_narrow":
            model = GoalDirectedNarrowHierarchyTopology()
        elif key == "gl_nn":
            model = GlNnTopology()
        elif key == "gl_nn_fg":
            model = GlFakeGateNnTopology()
        elif key == "super_hard":
            model = SingleExpertExperimentalTopology()
        elif key == "multi_dataset_alphabet":
            model = MultiDatasetAlphabetTopology()
        elif key == "nn-gradual-learning-demo":
            model = setup_demo_model()
        else:
            raise NotImplementedError

        model.assign_ids()

        return model

    # Create simulation, it is registers itself to observer_system
    with observer_system_context(storage_file) as observer_system:
        # run_topology_factory_with_ui(topology_factory=topology_factory,
        #                              topology_params={'key': args.model},
        #                              seed=seed,
        #                              max_steps=0,
        #                              auto_start=False,
        #                              observer_system=observer_system)
        # A simpler version which doesn't recreate the topology, just restarts.
        run_topology_with_ui(topology=topology_factory(args.model),
                             seed=seed,
                             max_steps=0,
                             auto_start=False,
                             observer_system=observer_system)

    print('Running simulation, press enter to quit.')
    input()
Пример #9
0
                                  flock_lr=0.01,
                                  gate_lr=0.05,  # 0.005 worked, 0.001 is safer
                                  coefficients_min_max=0.3,  # 0.001 used
                                  predictor_hidden_s=30,
                                  predictor_n_layers=3,
                                  use_teleport=True)
    else:
        model = SwitchableWorldTopology(temporal_class_definitions=classes, sx=sx, sy=sy)

    return model


if __name__ == '__main__':

    # configure the experiment
    model = setup_demo_model()

    model.assign_ids()
    seed = 1123

    # Create simulation, it is registers itself to observer_system
    with observer_system_context('observers.yaml') as observer_system:
        run_topology_with_ui(topology=model,
                             seed=seed,
                             max_steps=0,
                             auto_start=False,
                             observer_system=observer_system)

    print('Running simulation, press enter to quit.')
    input()
Пример #10
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--model", default="gl_nn")
    parser.add_argument("--sequences", default="s0", nargs='*')
    parser.add_argument("--seed", type=int, help="Global random seed.")
    parser.add_argument("--n-predictors",
                        type=int,
                        default=2,
                        help="Number of predictors.")
    parser.add_argument("--random-seed",
                        action='store_true',
                        help="Use random seed. Overrides the seed argument.")
    args = parser.parse_args()

    # UI persistence storage file - set to None to turn off the persistence
    storage_file = 'observers.yaml'

    if args.random_seed:
        seed = None
    else:
        seed = args.seed if args.seed is not None else 1337

    def topology_factory(key, seq_list) -> Topology:
        fourth_sequence_excluded = np.array([[0.8, 0.1, 0.1, 0.0],
                                             [0.1, 0.8, 0.1, 0.0],
                                             [0.1, 0.1, 0.8, 0.0],
                                             [1.0, 0.0, 0.0, 0.0]])
        cycle_except_third = np.array([[0.0, 1.0, 0.0, 0.0],
                                       [0.0, 0.0, 0.0, 1.0],
                                       [0.0, 0.0, 0.0, 1.0],
                                       [1.0, 0.0, 0.0, 0.0]])
        sequence_table = {
            "s0":
            SequenceGenerator([
                [1, 2, 3, 1, 2, 3, 1, 2, 3],
                [5, 4, 3, 5, 4, 3, 5, 4, 3],
                [1, 2, 3, 1, 2, 3, 1, 2, 3],
                [5, 4, 3, 5, 4, 3, 5, 4, 3],
            ], diagonal_transition_matrix(4, 0.8)),
            "s1":
            SequenceGenerator([
                [1, 2, 3, 1, 2, 3, 1, 2, 3],
                [2, 1, 3, 2, 1, 3, 2, 1, 3],
                [1, 2, 3, 1, 2, 3, 1, 2, 3],
                [5, 4, 3, 5, 4, 3, 5, 4, 3],
            ], diagonal_transition_matrix(4, 0.8)),
            "s2":
            SequenceGenerator(
                [[1, 2, 3, 1, 2, 3, 1, 2, 3], [2, 1, 3, 2, 1, 3, 2, 1, 3],
                 [1, 2, 3, 1, 2, 3, 1, 2, 3], [1]], fourth_sequence_excluded),
            "test":
            SequenceGenerator([
                [1, 2, 3, 1, 2, 3, 1, 2, 3],
                [2, 1, 3, 2, 1, 3, 2, 1, 3],
                [1, 2, 3, 1, 2, 3, 1, 2, 3],
                [5, 4, 3, 5, 4, 3, 5, 4, 3],
            ], cycle_except_third)
        }

        seqs = [sequence_table[seq] for seq in seq_list]

        if key == "gl_nn":
            model = GlNnTopology(seqs, args.n_predictors)
        elif key == "gl_nn_fg":
            model = GlFakeGateNnTopology()
        else:
            raise NotImplementedError

        model.assign_ids()

        return model

    # Create simulation, it is registers itself to observer_system
    with observer_system_context(storage_file) as observer_system:
        run_topology_with_ui(topology=topology_factory(args.model,
                                                       args.sequences),
                             seed=seed,
                             max_steps=0,
                             auto_start=False,
                             observer_system=observer_system)

    print('Running simulation, press enter to quit.')
    input()