def on_runButton_clicked(self): if self.ui.neighbourhoodEnabled.isChecked(): neighbourhood = NeighbourhoodUtil.get_neighbourhood( str(self.ui.neighbourhoodFunctionSelector.currentText()) )() topology = TopologyUtil.get_topology( str(self.ui.topologySelector.currentText()), neighbourhood, int(self.ui.initialNeighbourhoodRadius.text()), int(self.ui.topologyRowsValue.text()), int(self.ui.topologyColsValue.text()), ) else: topology = NoTopology() self.metric = MetricUtil.get_metric(str(self.ui.metricSelector.currentText()))() learning_factor = LearningFactorUtil.get_factor( str(self.ui.kohonenLearningFactorSelector.currentText()), float(self.ui.kohonenLearningFactorInitialValue.text()), int(self.ui.kohonenLearningIterations.text()), ) conscience_threshold = ( float(self.ui.conscienceThresholdValue.text()) if self.ui.conscienceEnabled.isChecked() else 0 ) kohonen_learning_iterations = int(self.ui.kohonenLearningIterations.text()) kohonen_learning = CounterPropagationKohonenLearning( self.network_layer, topology, self.metric, learning_factor, conscience_threshold ) learning_data = self.input_view.get_data() grossberg_learning_rule = RulesUtil.get_rule(self.ui.learningRuleSelector.currentText()) grossberg_learning_factor = LearningFactorUtil.get_factor( str(self.ui.grossbergLearningFactorSelector.currentText()), float(self.ui.grossbergLearningFactorInitialValue.text()), int(self.ui.grossbergLearningIterations.text()), ) grossberg_learning_iterations = int(self.ui.grossbergLearningIterations.text()) cp_learning = CounterPropagationLearning( self.network, grossberg_learning_rule, grossberg_learning_factor, kohonen_learning ) cp_learning.learn(kohonen_learning_iterations, grossberg_learning_iterations, learning_data) self.accept()
def _setup_gui(self): self.ui.topologyDimensionsBox.hide() self.ui.topologySelector.addItems(TopologyUtil.registered_topologies()) self.ui.topologySelector.setCurrentIndex(self.ui.topologySelector.findText(TopologyUtil.default_topology())) self.ui.neighbourhoodFunctionSelector.addItems(NeighbourhoodUtil.registered_neighbourhoods()) self.ui.neighbourhoodFunctionSelector.setCurrentIndex( self.ui.neighbourhoodFunctionSelector.findText(NeighbourhoodUtil.default_neighbourhood()) ) self.ui.metricSelector.addItems(MetricUtil.registered_metrics()) self.ui.metricSelector.setCurrentIndex(self.ui.metricSelector.findText(MetricUtil.default_metric())) self.ui.kohonenLearningFactorSelector.addItems(LearningFactorUtil.registered_factors()) self.ui.kohonenLearningFactorSelector.setCurrentIndex( self.ui.kohonenLearningFactorSelector.findText(LearningFactorUtil.default_factor()) ) self.ui.grossbergLearningFactorSelector.addItems(LearningFactorUtil.registered_factors()) self.ui.grossbergLearningFactorSelector.setCurrentIndex( self.ui.grossbergLearningFactorSelector.findText(LearningFactorUtil.default_factor()) ) self.ui.learningRuleSelector.addItems(RulesUtil.rules()) self.ui.learningRuleSelector.setCurrentIndex(self.ui.learningRuleSelector.findText(RulesUtil.default_layer())) self.ui.conscienceThresholdValue.setText(str(1 - round(float(1.0 / self.network.inputs_count()), 2) - 0.01))