File: cnn_examples.py

package info (click to toggle)
python-pyclustering 0.10.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 38,888; python: 24,311; sh: 384; makefile: 105
file content (75 lines) | stat: -rwxr-xr-x 2,618 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""!

@brief Examples of usage and demonstration of abilities of chaotic oscillatory network.

@authors Andrei Novikov (pyclustering@yandex.ru)
@date 2014-2020
@copyright BSD-3-Clause

"""

from pyclustering.nnet.cnn import cnn_network, cnn_visualizer, type_conn;

from pyclustering.samples.definitions import SIMPLE_SAMPLES, FCPS_SAMPLES;

from pyclustering.utils import read_sample;


def template_dynamic_cnn(num_osc, steps, stimulus, neighbors, connection, show_network = False):
    network_instance = cnn_network(num_osc, connection, amount_neighbors = neighbors);
    
    output_dynamic = network_instance.simulate(steps, stimulus);
    print(output_dynamic.allocate_sync_ensembles(10));
    
    if (show_network is True):
        network_instance.show_network();
    
    cnn_visualizer.show_output_dynamic(output_dynamic);
    cnn_visualizer.show_dynamic_matrix(output_dynamic);
    cnn_visualizer.show_observation_matrix(output_dynamic);


def chaotic_clustering_sample_simple_01():
    sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE1);
    template_dynamic_cnn(len(sample), 100, sample, 3, type_conn.ALL_TO_ALL);


def chaotic_clustering_triangulation_sample_simple_01():
    sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE1);
    template_dynamic_cnn(len(sample), 100, sample, 3, type_conn.TRIANGULATION_DELAUNAY);


def chaotic_clustering_sample_simple_02():
    sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE2);
    template_dynamic_cnn(len(sample), 100, sample, 3, type_conn.ALL_TO_ALL);


def chaotic_clustering_triangulation_sample_simple_02():
    sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE2);
    template_dynamic_cnn(len(sample), 100, sample, 5, type_conn.TRIANGULATION_DELAUNAY);


def chaotic_clustering_sample_simple_03():
    sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE3);
    template_dynamic_cnn(len(sample), 100, sample, 10, type_conn.ALL_TO_ALL);


def chaotic_clustering_sample_simple_04():
    sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE4);
    template_dynamic_cnn(len(sample), 100, sample, 5, type_conn.ALL_TO_ALL);


def chaotic_clustering_fcps_lsun():
    sample = read_sample(FCPS_SAMPLES.SAMPLE_LSUN);
    template_dynamic_cnn(len(sample), 100, sample, 10, type_conn.ALL_TO_ALL);


chaotic_clustering_sample_simple_01();
chaotic_clustering_triangulation_sample_simple_01();
chaotic_clustering_sample_simple_02();
chaotic_clustering_triangulation_sample_simple_02();
chaotic_clustering_sample_simple_03();
chaotic_clustering_sample_simple_04();

chaotic_clustering_fcps_lsun();