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


Python syncpr.syncpr函数代码示例

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


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

示例1: templateOutputDynamicLengthStaticSimulation

 def templateOutputDynamicLengthStaticSimulation(collect_flag, ccore_flag):
     net = syncpr(5, 0.1, 0.1, ccore_flag);
     output_dynamic = net.simulate_static(10, 10, [-1, 1, -1, 1, -1], solution = solve_type.FAST, collect_dynamic = collect_flag);
      
     if (collect_flag is True):
         assert len(output_dynamic) == 11; # 10 steps without initial values.
     else:
         assert len(output_dynamic) == 1;
开发者ID:annoviko,项目名称:pyclustering,代码行数:8,代码来源:syncpr_templates.py

示例2: templateOutputDynamicLengthDynamicSimulation

 def templateOutputDynamicLengthDynamicSimulation(collect_flag, ccore_flag):
     net = syncpr(5, 0.1, 0.1, ccore_flag);
     output_dynamic = net.simulate_dynamic([-1, 1, -1, 1, -1], solution = solve_type.FAST, collect_dynamic = collect_flag);
      
     if (collect_flag is True):
         assert len(output_dynamic) > 1;
     else:
         assert len(output_dynamic) == 1;
开发者ID:annoviko,项目名称:pyclustering,代码行数:8,代码来源:syncpr_templates.py

示例3: templateStaticSimulation

 def templateStaticSimulation(ccore_falg):
     net = syncpr(10, 0.1, 0.1, ccore_falg);
      
     patterns =  [];
     patterns += [ [1, 1, 1, 1, 1, -1, -1, -1, -1, -1] ];
     patterns += [ [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1] ];
      
     net.train(patterns);
     net.simulate_static(20, 10, patterns[0], solve_type.RK4);
     memory_order = net.memory_order(patterns[0]);
      
     assert (memory_order > 0.95) and (memory_order <= 1.000005);
开发者ID:annoviko,项目名称:pyclustering,代码行数:12,代码来源:syncpr_templates.py

示例4: templateDynamicSimulation

 def templateDynamicSimulation(ccore_flag):
     net = syncpr(10, 0.1, 0.1, ccore_flag);
      
     patterns =  [];
     patterns += [ [1, 1, 1, 1, 1, -1, -1, -1, -1, -1] ];
     patterns += [ [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1] ];
      
     net.train(patterns);
     net.simulate_dynamic(patterns[0], order = 0.998, solution = solve_type.RK4);
     memory_order = net.memory_order(patterns[0]);
      
     assert (memory_order > 0.998) and (memory_order <= 1.0);
开发者ID:annoviko,项目名称:pyclustering,代码行数:12,代码来源:syncpr_templates.py

示例5: templateGlobalSyncOrder

 def templateGlobalSyncOrder(self, ccore_flag):
     net = syncpr(10, 0.1, 0.1, ccore_flag);
     
     patterns =  [ [1, 1, 1, 1, 1, -1, -1, -1, -1, -1] ];
     patterns += [ [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1] ];
     
     global_sync_order = net.sync_order();
     assert (global_sync_order < 1.0) and (global_sync_order > 0.0);
     
     net.train(patterns);
     
     global_sync_order = net.sync_order();
     assert (global_sync_order < 1.0) and (global_sync_order > 0.0);
开发者ID:abhishek792,项目名称:pyclustering,代码行数:13,代码来源:syncpr_tests.py

示例6: templateLocalSyncOrder

 def templateLocalSyncOrder(ccore_flag):
     net = syncpr(10, 0.1, 0.1, ccore_flag);
     
     patterns =  [ [1, 1, 1, 1, 1, -1, -1, -1, -1, -1] ];
     patterns += [ [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1] ];
     
     local_sync_order = net.sync_local_order();
     assert (local_sync_order < 1.0) and (local_sync_order > 0.0);
     
     net.train(patterns);
     
     local_sync_order = net.sync_local_order();
     assert (local_sync_order < 1.0) and (local_sync_order > 0.0);
开发者ID:annoviko,项目名称:pyclustering,代码行数:13,代码来源:syncpr_templates.py

示例7: templateMemoryOrder

 def templateMemoryOrder(ccore_flag):
     net = syncpr(10, 0.1, 0.1, ccore_flag);
     
     patterns =  [];
     patterns += [ [1, 1, 1, 1, 1, -1, -1, -1, -1, -1] ];
     patterns += [ [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1] ];
     
     net.train(patterns);
     assert net.memory_order(patterns[0]) < 0.8;
     assert net.memory_order(patterns[1]) < 0.8;
     
     for pattern in patterns:
         net.simulate(20, 10, pattern, solve_type.RK4);
         memory_order = net.memory_order(pattern);
         assert (memory_order > 0.95) and (memory_order <= 1.000005);
开发者ID:annoviko,项目名称:pyclustering,代码行数:15,代码来源:syncpr_templates.py

示例8: template_recognition_image

def template_recognition_image(images, steps, time, corruption = 0.1):
    samples = [];
    
    for file_name in images:
        data = read_image(file_name);
                
        image_pattern = rgb2gray(data);
                
        for index_pixel in range(len(image_pattern)):
            if (image_pattern[index_pixel] < 128):
                image_pattern[index_pixel] = 1;
            else:
                image_pattern[index_pixel] = -1;
                
        samples += [ image_pattern ];
    
    net = syncpr(len(samples[0]), 0.3, 0.3, ccore = True);
    net.train(samples);
    
    # Recognize the each learned pattern
    for i in range(len(samples)):
        sync_output_dynamic = net.simulate(steps, time, samples[i], solve_type.RK4, True);
        syncpr_visualizer.show_output_dynamic(sync_output_dynamic);
        syncpr_visualizer.show_pattern(sync_output_dynamic, 10, 10);
        
        # corrupt a little bit by black and white pixels
        for _ in range( math.floor(len(samples[i]) * corruption) ):
            random.seed();
            random_pixel = math.floor(random.random() * len(samples[i]));
            samples[i][random_pixel] = 1;
            
            random_pixel = math.floor(random.random() * len(samples[i]));
            samples[i][random_pixel] = -1;
        
        sync_output_dynamic = net.simulate(steps, time, samples[i], solve_type.RK4, True);
        syncpr_visualizer.show_output_dynamic(sync_output_dynamic);
        syncpr_visualizer.show_pattern(sync_output_dynamic, 10, 10);

        syncpr_visualizer.animate_pattern_recognition(sync_output_dynamic, 10, 10, title = "Pattern Recognition");
开发者ID:annoviko,项目名称:pyclustering,代码行数:39,代码来源:syncpr_examples.py

示例9: templateTrainNetworkAndRecognizePattern

 def templateTrainNetworkAndRecognizePattern(ccore_flag):
     net = syncpr(10, 0.1, 0.1, ccore_flag);
      
     patterns =  [];
     patterns += [ [1, 1, 1, 1, 1, -1, -1, -1, -1, -1] ];
     patterns += [ [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1] ];
      
     net.train(patterns);
      
     # recognize it
     for i in range(len(patterns)):
         output_dynamic = net.simulate(10, 10, patterns[i], solve_type.RK4, True);
          
         ensembles = output_dynamic.allocate_sync_ensembles(0.5);
         assert len(ensembles) == 2;
         assert len(ensembles[0]) == len(ensembles[1]);
          
         # sort results
         ensembles[0].sort();
         ensembles[1].sort();
          
         assert (ensembles[0] == [0, 1, 2, 3, 4]) or (ensembles[0] == [5, 6, 7, 8, 9]);
         assert (ensembles[1] == [0, 1, 2, 3, 4]) or (ensembles[1] == [5, 6, 7, 8, 9]);
开发者ID:annoviko,项目名称:pyclustering,代码行数:23,代码来源:syncpr_templates.py

示例10: templateIncorrectPatternForSimulation

 def templateIncorrectPatternForSimulation(self, pattern):
     net = syncpr(10, 0.1, 0.1);
      
     self.assertRaises(Exception, net.simulate, 10, 10, pattern);
开发者ID:abhishek792,项目名称:pyclustering,代码行数:4,代码来源:syncpr_tests.py

示例11: templateIncorrectPatternForTraining

 def templateIncorrectPatternForTraining(patterns, ccore_flag):
     net = syncpr(10, 0.1, 0.1, ccore_flag);
     try: net.train(patterns);
     except: return;
     assert False;
开发者ID:annoviko,项目名称:pyclustering,代码行数:5,代码来源:syncpr_templates.py

示例12: templatePatternVisualizer

 def templatePatternVisualizer(self, collect_dynamic):
     net = syncpr(5, 0.1, 0.1);
     output_dynamic = net.simulate(10, 10, [-1, 1, -1, 1, -1], solve_type.RK4, collect_dynamic);
      
     # test that we don't have any exception during vizualization.
     syncpr_visualizer.show_pattern(output_dynamic, 5, 2);
开发者ID:abhishek792,项目名称:pyclustering,代码行数:6,代码来源:syncpr_tests.py

示例13: templateOutputDynamic

 def templateOutputDynamic(solver, ccore):
     net = syncpr(5, 0.1, 0.1, ccore);
     output_dynamic = net.simulate(10, 10, [-1, 1, -1, 1, -1], solver, True);
      
     assert len(output_dynamic) == 11; # 10 steps without initial values.
开发者ID:annoviko,项目名称:pyclustering,代码行数:5,代码来源:syncpr_templates.py

示例14: testCreateTenOscillatorsNetwork

 def testCreateTenOscillatorsNetwork(self):
     net = syncpr(10, 0.1, 0.1);
     assert len(net) == 10;
开发者ID:abhishek792,项目名称:pyclustering,代码行数:3,代码来源:syncpr_tests.py

示例15: testOutputDinamicLengthSimulation

 def testOutputDinamicLengthSimulation(self):
     net = syncpr(5, 0.1, 0.1);
     output_dynamic = net.simulate(10, 10, [-1, 1, -1, 1, -1], solution = solve_type.FAST, collect_dynamic = True);
      
     assert len(output_dynamic) == 11; # 10 steps without initial values.
开发者ID:abhishek792,项目名称:pyclustering,代码行数:5,代码来源:syncpr_tests.py


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