예제 #1
0
def create_gng(max_nodes, n_inputs, step=0.2, n_start_nodes=2, max_edge_age=50):
	return algorithms.GrowingNeuralGas(
		n_inputs=n_inputs,
		n_start_nodes=n_start_nodes,

		shuffle_data=True,
		verbose=False,

		step=step,
		neighbour_step=0.005,

		max_edge_age=max_edge_age,
		max_nodes=max_nodes,

		n_iter_before_neuron_added=100,
		after_split_error_decay_rate=0.5,
		error_decay_rate=0.995,
		min_distance_for_update=0.01,
	)
# Run GNG
from neupy import algorithms, utils
utils.reproducible()

#gng with 3 features, because the data is 3-D now
gng = algorithms.GrowingNeuralGas(
    n_inputs=4,
    n_start_nodes=2,
    shuffle_data=True,
    verbose=False,
    step=0.1,
    neighbour_step=0.001,
    max_edge_age=50,
    # Before this was 1000
    max_nodes=10000,

    # To get 5000 notes, this was 2
    # To get 554 nodes, this was 20
    # To get 112 nodes, this was 100
    n_iter_before_neuron_added=20,
    after_split_error_decay_rate=0.5,
    error_decay_rate=0.995,
    min_distance_for_update=0.2,
)


def run_gng(data, i):
    # Training will slow down overtime and we increase number
    # of data samples for training
    #n = int(0.5 * gng.n_iter_before_neuron_added * (1 + i // 100))
예제 #3
0
파일: run_gng.py 프로젝트: wkt1227/galaxy
    sample_vectors = np.array([p.sv for p in patches])

    sv_len = len(sample_vectors[0])

    utils.reproducible()

    gng = algorithms.GrowingNeuralGas(
        n_inputs=sv_len,
        n_start_nodes=2,

        shuffle_data=True,
        verbose=False,

        step=0.1,
        neighbour_step=0.001,

        max_edge_age=70,
        max_nodes=250,
        n_iter_before_neuron_added=200,

        after_split_error_decay_rate = 0.5,
        error_decay_rate=0.995,
        min_distance_for_update=0.2,
    )

    gng.train(sample_vectors, epochs=40)

    nodes = []
    
    for node in gng.graph.nodes:
        nodes.append(node.weight[0])