Esempio n. 1
0
        public SOM(AppSettings appSettings )
        {
            _appSettings = appSettings;
            _netState = NET_STATE.init;
            _trainingPhase = TRAINING_PHASE.phase_1;
            _currentIteration = 1;
            _totalMapError = 0.0f;
            _isNeuronSelected = false;
            _selectedNeuronCoords = new Point( 0, 0 );
            _isTrained = false;

            _timeConstant_P1 = (float)_appSettings.numIterations_P1 / (float)Math.Log( _appSettings.mapRadius );
            _learningRate_P1 = _appSettings.startLearningRate_P1;
            _learningRate_P2 = _appSettings.startLearningRate_P2;

            // Allocate memory.
            _competitionLayer = new Neuron[ SOMConstants.NUM_NODES_DOWN, SOMConstants.NUM_NODES_ACROSS ];
            for ( int i = 0; i < SOMConstants.NUM_NODES_DOWN; ++i ) {
                for ( int j = 0; j < SOMConstants.NUM_NODES_ACROSS; ++j ) {
                    _competitionLayer[ i,j ] = new Neuron( i, j );
                }
            }
            _errorMap = new float[ SOMConstants.NUM_NODES_DOWN, SOMConstants.NUM_NODES_ACROSS, 3 ];

            Run();
        }
Esempio n. 2
0
        public MainWindow()
        {
            InitializeComponent();
            // Initialize application setting for SOM and its visual
            _appSettings = new AppSettings();
            UpdateAppSettings();

            // Initialize SOM
            _som = new SOM(_appSettings);

            // Initialize visual for competition layer
            visualHost_CompetitionLayer = new SOMVisual(SOMVisualType.COMPETITION_LAYER_MAP, SOMConstants.NUM_NODES_ACROSS,
                (int)_appSettings.width, (int)_appSettings.height, _som);
            canvas_CompetitionLayer.Children.Add(visualHost_CompetitionLayer);

            // Initialize visual for error map
            visualHost_ErrorMap = new SOMVisual(SOMVisualType.ERROR_MAP, SOMConstants.NUM_NODES_ACROSS,
                (int)_appSettings.width, (int)_appSettings.height, _som);
            canvas_ErrorMap.Children.Add(visualHost_ErrorMap);

            // Initialize histograms
            for (int i = 0; i < SOMConstants.NUM_WEIGHTS; i++)
            {
                NeuronHistogram.DataItems.Add(new ColumnDataPoint());
                FeatureHistogram.DataItems.Add(new ColumnDataPoint());
            }

            CompositionTarget.Rendering += CompositionTarget_Rendering;
        }
Esempio n. 3
0
        private void UpdateAppSettings()
        {
            if (_appSettings == null)
            {
                _appSettings = new AppSettings();
            }

            // Initialization fill
            if (radioButton_Random.IsChecked == true)
            {
                _appSettings.initFill = INIT_FILL.random;
            }
            else if (radioButton_Gradient.IsChecked == true)
            {
                _appSettings.initFill = INIT_FILL.gradient;
            }

            // Assumes both rendering canvases are of the same dimension
            _appSettings.width = (float)canvas_CompetitionLayer.Width;
            _appSettings.height = (float)canvas_CompetitionLayer.Height;

            // Calculate competition layer dimension
            _appSettings.nodeWidth = _appSettings.width / (float)SOMConstants.NUM_NODES_ACROSS;
            _appSettings.nodeHeight = _appSettings.height / (float)SOMConstants.NUM_NODES_DOWN;

            _appSettings.mapRadius = Math.Max(_appSettings.width, _appSettings.height) / 2.0f;

            // Initialize learning rates
            _appSettings.startLearningRate_P1 = (float)decimalUpDown_LearningRateP1.Value;
            _appSettings.startLearningRate_P2 = (float)decimalUpDown_LearningRateP2.Value;

            // Initialize iterations
            _appSettings.numIterations_P1 = (int)integerUpDown_IterationP1.Value;
            _appSettings.numIterations_P2 = (int)integerUpDown_IterationP2.Value;

            _appSettings.imageDirectory = textBox_ImageDirectory.Text;

            GetInputVectors();
        }