Beispiel #1
0
def set_parameter(age,lambda_set,alpha_set,min_cluster,if_delete):
    """Initilization of SOINN, calling this function after training will reset the
    neural network for further training. age, lambda_set, alpha_set,min_cluster,if_delete
    are the SOINN parameters meaning max age, learning step, neuron clustering coefficient,
    minimum desired clusters and a choice whether to delete the neurons without neighbors
    in the final round of training."""
    global age_max
    global nn_lambda
    global alpha
    global setN
    global accumulated
    global numbers
    global density
    global big_clusters
    global t
    global minimum_cluster
    global gr
    global delete_noise
    delete_noise = if_delete
    t = 1
    setN = []
    accumulated = [1,1]
    numbers = [1,1]
    setLabel = [0,0]
    big_clusters = []
    density = []
    nn_lambda = lambda_set
    age_max = age
    alpha = alpha_set
    minimum_cluster = min_cluster
    gr = graph()
    return
Beispiel #2
0
def set_parameter(age, lambda_set, ann_set, bnn_set, eb_, en_):
    """Initilization of GNG, calling this function after training will reset the
    neural network for further training. age, lambda_set, ann_set, bnn_set, eb_,
    en_ are the GNG parameters meaning max age, learning step, winner adaptation size,
    neighbor of winner adaptation size, and error reduction sizes."""
    global age_max  #:max age parameter of GNG
    global nn_lambda  #:training step of GNG
    global alpha
    global setN  #:set of neuron weights
    global accumulated  #:winning times of each neuron
    global numbers
    global density
    global big_clusters  #:a dictionary stating which cluster of a neuron belong to
    global t
    global minimum_cluster
    global gr
    global delete_noise
    global eb
    global en
    global ann
    global bnn
    global accumulated_error
    ann = ann_set
    bnn = bnn_set
    eb = eb_
    en = en_
    t = 1
    setN = []
    accumulated = [1, 1]
    accumulated_error = [0, 0]
    numbers = [1, 1]
    big_clusters = []
    density = []
    nn_lambda = lambda_set
    age_max = age
    gr = graph()
    return
Beispiel #3
0
"""The single layer SOINN algorithm procedures, for developers only."""
from numpy import *
from . import __grouping2 as grouping2
from math import isnan
from oldgraph.classes.graph import graph

winner_index = 0
winner_2nd_index = 0
setN = [] #:neuron weights
gr = graph() #:topology structure implemented by python-graph
T_winner = 0
T_2nd_winner = 0
accumulated = [1,1]
big_clusters = []
density = []
age_max = 0
nn_lambda = 0
alpha = 0
t = 1
numbers = [1,1]
setLabel = [0,0]
miminum_cluster = 2
delete_noise = False


def set_parameter(age,lambda_set,alpha_set,min_cluster,if_delete):
    """Initilization of SOINN, calling this function after training will reset the
    neural network for further training. age, lambda_set, alpha_set,min_cluster,if_delete
    are the SOINN parameters meaning max age, learning step, neuron clustering coefficient,
    minimum desired clusters and a choice whether to delete the neurons without neighbors
    in the final round of training."""
Beispiel #4
0
            ##            print 'cut tree',yourcut.values(),grade
            yourset = list(yourcut.values())
            for i in range(grade):
                print(min(yourset))
                yourset.remove(min(yourset))
            max_degree = min(yourset)
            ##            print max_degree,yourset

            for edge_name, cut_degree in list(yourcut.items()):
                if (cut_degree < max_degree + 1) and (gr.has_edge(edge_name)):
                    ##                    print edge_name
                    gr.del_edge(edge_name)
                    print('cluster break x 1', edge_name)

if __name__ == '__main__':
    gr = graph()
    setN = [
        array([0.0, 0.0]),
        array([1.0, 0.0]),
        array([0.5, 0.5]),
        array([0.5, 1.0]),
        array([-0.1, -0.1]),
        array([2.0, 1.0]),
        array([2.0, 0.0]),
        array([1.5, 0.5])
    ]
    gr.add_nodes(list(range(8)))
    gr.add_edge((0, 1))
    gr.add_edge((0, 2))
    gr.add_edge((2, 1))
    gr.add_edge((3, 2))