本文整理汇总了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);
示例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;
示例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;
示例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;
示例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;
示例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;
示例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;
示例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;
示例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);
示例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);
示例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;
示例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;
示例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;
示例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;
示例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;