def dialog(network, learning_data): layers = network.get_layers() if Layers.get_type(layers[0]) == Layers.KOHONEN_LAYER: if len(layers) == 2 and Layers.get_type(layers[1]) == Layers.GENERAL_LAYER: return CounterPropagationLearningDialog(network) else: return KohonenLearningDialog(network) else: return BackPropagationLearningDialog(network, learning_data)
def from_network(network): model = NetworkModel(empty=True) model.set_network_input_neurons(network.inputs_count()) for layer in network.get_layers(): layer_model = model.add_layer() neurons = layer.get_neurons() layer_model.set_layer_type(Layers.get_type(layer)) layer_model.set_neurons(len(neurons)) for neuron_index in range(len(neurons)): neuron = neurons[neuron_index] layer_model.set_psp_for_neuron(neuron_index, neuron.get_psp().NAME) layer_model.set_activation_for_neuron(neuron_index, neuron.get_activator().NAME) layer_model.set_bias_for_neuron(neuron_index, neuron.get_bias().get_weight()) inputs = neuron.get_inputs() for input_index in range(len(inputs)): layer_model.set_weight_for_connection(neuron_index, input_index, round(neuron.get_input_edge(input_index).get_weight(), 3)) return model