当前位置: 首页>>代码示例>>Python>>正文


Python legion.legion_network函数代码示例

本文整理汇总了Python中pyclustering.nnet.legion.legion_network函数的典型用法代码示例。如果您正苦于以下问题:Python legion_network函数的具体用法?Python legion_network怎么用?Python legion_network使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了legion_network函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: template_segmentation_image

def template_segmentation_image(image_file, parameters, steps, time, ccore_flag = True):
    image = read_image(image_file);
    stimulus = rgb2gray(image);
    
    for pixel_index in range(len(stimulus)):
        if (stimulus[pixel_index] < 235): stimulus[pixel_index] = 1;
        else: stimulus[pixel_index] = 0;
    
    if (parameters is None):
        parameters = legion_parameters();
    
    net = legion_network(len(stimulus), parameters, conn_type.GRID_FOUR, ccore = ccore_flag);
    output_dynamic = net.simulate(steps, time, stimulus);
    
    ensembles = output_dynamic.allocate_sync_ensembles();
    
    draw_image_mask_segments(image_file, ensembles);
    # draw_dynamics(output_dynamic.time, output_dynamic.output, x_title = "Time", y_title = "x(t)", separate = ensembles);
    
    # just for checking correctness of results - let's use classical algorithm
    dbscan_instance = dbscan(image, 3, 4, True);
    dbscan_instance.process();
    trustable_clusters = dbscan_instance.get_clusters();
    
    draw_dynamics(output_dynamic.time, output_dynamic.output, x_title = "Time", y_title = "x(t)", separate = trustable_clusters);
开发者ID:Gudui,项目名称:pyclustering,代码行数:25,代码来源:legion_segmentation.py

示例2: templateOutputDynamicInformation

 def templateOutputDynamicInformation(stimulus, params, type_conn, sim_steps, sim_time, ccore_flag):
     legion_instance = legion_network(len(stimulus), params, type_conn, ccore = ccore_flag);
     dynamic = legion_instance.simulate(sim_steps, sim_time, stimulus);
      
     assert len(dynamic.output) > 0;
     assert len(dynamic.inhibitor) > 0;
     assert len(dynamic.time) > 0;
开发者ID:annoviko,项目名称:pyclustering,代码行数:7,代码来源:legion_templates.py

示例3: testListConnectionRepresentation

    def testListConnectionRepresentation(self):
        net = legion_network(3, [1, 0, 1], type_conn = conn_type.LIST_BIDIR, type_conn_represent = conn_represent.LIST);
        (t, x, z) = net.simulate(1000, 2000);
 
        assert extract_number_oscillations(x, 0) > 1;
        assert extract_number_oscillations(x, 1) == 1;   
        assert extract_number_oscillations(x, 2) > 1;  
开发者ID:weihuang0908,项目名称:pyclustering,代码行数:7,代码来源:legion_tests.py

示例4: testMixStimulatedThreeOscillators

 def testMixStimulatedThreeOscillators(self):
     net = legion_network(3, [1, 0, 1], type_conn = conn_type.LIST_BIDIR);
     (t, x, z) = net.simulate(1000, 2000);
      
     assert extract_number_oscillations(x, 0) > 1;
     assert extract_number_oscillations(x, 1) == 1;   
     assert extract_number_oscillations(x, 2) > 1;       
开发者ID:weihuang0908,项目名称:pyclustering,代码行数:7,代码来源:legion_tests.py

示例5: testStimulatedOscillatorWithoutLateralPotential

 def testStimulatedOscillatorWithoutLateralPotential(self):
     params = legion_parameters();
     params.teta = 0;    # because no neighbors at all
      
     net = legion_network(1, type_conn = conn_type.NONE, parameters = params, ccore = False);
     dynamic = net.simulate(2000, 400, [1]);
      
     assert extract_number_oscillations(dynamic.output) > 1;
开发者ID:annoviko,项目名称:pyclustering,代码行数:8,代码来源:ut_legion.py

示例6: testUstimulatedOscillatorWithoutLateralPotential

 def testUstimulatedOscillatorWithoutLateralPotential(self):
     params = legion_parameters();
     params.teta = 0;    # because no neighbors at all
   
     net = legion_network(1, type_conn = conn_type.NONE, parameters = params, ccore = False);
     dynamic = net.simulate(1000, 200, [0]);
      
     assert extract_number_oscillations(dynamic.output, amplitude_threshold = 0.0) == 0;
开发者ID:annoviko,项目名称:pyclustering,代码行数:8,代码来源:ut_legion.py

示例7: testStimulatedOscillatorWithoutLateralPotential

 def testStimulatedOscillatorWithoutLateralPotential(self):
     params = legion_parameters();
     params.teta = 0;    # because no neighbors at all
      
     net = legion_network(1, [1], type_conn = conn_type.NONE, parameters = params);
     (t, x, z) = net.simulate(1000, 200);
      
     assert extract_number_oscillations(x) > 1;      
开发者ID:weihuang0908,项目名称:pyclustering,代码行数:8,代码来源:legion_tests.py

示例8: testUnstimulatedTwoOscillators

 def testUnstimulatedTwoOscillators(self):
     params = legion_parameters();
     params.teta_p = 2.5;
      
     net = legion_network(2, [0, 0], type_conn = conn_type.LIST_BIDIR, parameters = params);
     (t, x, z) = net.simulate(1000, 1000);
      
     assert extract_number_oscillations(x, 0) == 1;
     assert extract_number_oscillations(x, 1) == 1;
开发者ID:weihuang0908,项目名称:pyclustering,代码行数:9,代码来源:legion_tests.py

示例9: template_dynamic_legion

def template_dynamic_legion(num_osc, steps, time, conn_type = conn_type.NONE, stimulus = None, params = None, separate_repr = True):
    net = legion_network(num_osc, stimulus, type_conn = conn_type, parameters = params);
    (t, x, z) = net.simulate(steps, time, solution = solve_type.RK4);
    
    draw_dynamics(t, x, x_title = "Time", y_title = "x(t)", separate = separate_repr);
    draw_dynamics(t, z, x_title = "Time", y_title = "z(t)");
    
    ensembles = net.allocate_sync_ensembles(0.1);
    print(ensembles);
开发者ID:weihuang0908,项目名称:pyclustering,代码行数:9,代码来源:legion_examples.py

示例10: template_dynamic_legion

def template_dynamic_legion(num_osc, steps, time, conn_type, stimulus, params = None, separate_repr = True, ccore_flag = True):
    net = legion_network(num_osc, params, conn_type, ccore = ccore_flag);
    print("Created");
    
    dynamic = net.simulate(steps, time, stimulus, solution = solve_type.RK4);
    print("Simulated");
    
    draw_dynamics(dynamic.time, dynamic.output, x_title = "Time", y_title = "x(t)", separate = separate_repr);
    draw_dynamics(dynamic.time, dynamic.inhibitor, x_title = "Time", y_title = "z(t)");
    
    ensembles = dynamic.allocate_sync_ensembles(0.1);
    print(ensembles);
开发者ID:alishakiba,项目名称:pyclustering,代码行数:12,代码来源:legion_examples.py

示例11: templateSyncEnsembleAllocation

 def templateSyncEnsembleAllocation(self, stimulus, params, type_conn, sim_steps, sim_time, expected_clusters, ccore_flag = False):
     result_testing = False;
     
     for _ in range(0, 3, 1):
         net = legion_network(len(stimulus), params, type_conn, ccore = ccore_flag);
         dynamic = net.simulate(sim_steps, sim_time, stimulus);
         
         ensembles = dynamic.allocate_sync_ensembles(0.1);
         if (ensembles != expected_clusters):
             continue;
         
         result_testing = True;
         break;
     
     assert result_testing;
开发者ID:terry07,项目名称:pyclustering,代码行数:15,代码来源:legion_tests.py

示例12: testStimulatedOscillatorWithLateralPotential

 def testStimulatedOscillatorWithLateralPotential(self):
     net = legion_network(1, type_conn = conn_type.NONE);
     dynamic = net.simulate(1000, 200, [1]);
      
     assert extract_number_oscillations(dynamic.output) == 1;
开发者ID:alishakiba,项目名称:pyclustering,代码行数:5,代码来源:legion_tests.py

示例13: templateOscillationsWithStructures

 def templateOscillationsWithStructures(self, type_conn):
     net = legion_network(4, [1, 1, 1, 1], type_conn = conn_type.LIST_BIDIR);
     (t, x, z) = net.simulate(500, 1000);
      
     for i in range(net.num_osc):
         assert extract_number_oscillations(x, i) > 1;
开发者ID:weihuang0908,项目名称:pyclustering,代码行数:6,代码来源:legion_tests.py

示例14: testListConnectionRepresentation

   def testListConnectionRepresentation(self):
       net = legion_network(3, type_conn = conn_type.LIST_BIDIR, type_conn_represent = conn_represent.LIST, ccore = False);
       dynamic = net.simulate(1000, 2000, [1, 0, 1]);
 
       assert extract_number_oscillations(dynamic.output, 0) > 1;  
       assert extract_number_oscillations(dynamic.output, 2) > 1;  
开发者ID:annoviko,项目名称:pyclustering,代码行数:6,代码来源:ut_legion.py

示例15: testMixStimulatedThreeOscillators

 def testMixStimulatedThreeOscillators(self):
     net = legion_network(3, type_conn = conn_type.LIST_BIDIR, ccore = False);
     dynamic = net.simulate(1000, 2000, [1, 0, 1]);
       
     assert extract_number_oscillations(dynamic.output, 0) > 1; 
     assert extract_number_oscillations(dynamic.output, 2) > 1;
开发者ID:annoviko,项目名称:pyclustering,代码行数:6,代码来源:ut_legion.py


注:本文中的pyclustering.nnet.legion.legion_network函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。