public void HugeDivisiveCPU()
        {
            int nDescriptors        = 350000;
            int descriptorDimension = 4096;

            int[] nClusters       = new int[] { 150, 150 };
            int[] iterationCounts = new int[] { 10, 10 };

            int nDescriptorsDiv5 = nDescriptors / 5;

            Descriptor[]       descriptors = HelperTestClass.GenerateHierarchicalDescriptors(seed, nDescriptorsDiv5, descriptorDimension);
            ClusteringDivisive clustering  = new ClusteringDivisive(descriptors);

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            clustering.Clusterize(nClusters, iterationCounts, seed);
            stopWatch.Stop();

            double elapsedSeconds = (stopWatch.ElapsedMilliseconds * 0.001);
            double nPerSecond     = nDescriptorsDiv5 * 5 * nClusters[0] * nClusters[1] / elapsedSeconds;

            Console.WriteLine("Computing time: " + elapsedSeconds + " seconds (" + nPerSecond + " per second).");

            HelperTestClass.VisualizeClustering(clustering.Descriptors, clustering.Centroids, windowSize, windowSize);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            CultureInfo customCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();

            customCulture.NumberFormat.NumberDecimalSeparator    = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;


            string descriptorFile = args[0];
            string outputFile     = args[1];
            int    iterationCount = int.Parse(args[2]);

            int argumentOffset = 3;

            int[] seedCounts      = new int[args.Length - argumentOffset];
            int[] iterationCounts = new int[args.Length - argumentOffset];
            for (int i = argumentOffset; i < args.Length; i++)
            {
                int seedIndex = i - argumentOffset;
                seedCounts[seedIndex]      = int.Parse(args[i]); // TODO: try-catch
                iterationCounts[seedIndex] = iterationCount;
            }

            int seed = 5334;

            Descriptor[] descriptors = LoadArrayDescriptors(descriptorFile);

            // debug
            //Descriptor[] descriptors = HelperTestClass.GenerateHierarchicalDescriptors(seed, 10000, 2);
            //seedCounts = new int[] { 10, 10 };

            ClusteringDivisive clustering = new ClusteringDivisive(descriptors);

            Console.WriteLine("Launching clusterization.");

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            clustering.Clusterize(seedCounts, iterationCounts, seed);
            stopWatch.Stop();

            Console.WriteLine("Clusterization finished.");
            int elapsedSeconds   = (int)(stopWatch.ElapsedMilliseconds / 1000);
            int hours            = (elapsedSeconds / (60 * 60));
            int secondsRemainder = (elapsedSeconds % (60 * 60));
            int minutes          = (secondsRemainder / 60);
            int seconds          = (secondsRemainder % 60);

            Console.WriteLine("Computing time: {0} hours, {1} minutes, {2} seconds.", hours, minutes, seconds);


            WriteToTextFile(clustering.Centroids[clustering.Centroids.Length - 1], outputFile);

            //int imageSize = 4096;
            //HelperTestClass.VisualizeClustering(clustering.Descriptors, clustering.Centroids, imageSize, imageSize);
            //HelperTestClass.VisualizeClustering(clustering.Descriptors, clustering.Centroids, imageSize * 2, imageSize * 2);
            //HelperTestClass.VisualizeClustering(clustering.Descriptors, clustering.Centroids, imageSize * 4, imageSize * 4);
            //HelperTestClass.VisualizeClustering(clustering.Descriptors, clustering.Centroids, imageSize * 8, imageSize * 8);
        }
        public void TestDescriptorAssignmentDivisive()
        {
            int[] nClusters       = new int[] { 10, 10 };
            int[] iterationCounts = new int[] { 10, 10 };

            ClusteringDivisive clustering = new ClusteringDivisive(descriptors);

            clustering.Clusterize(nClusters, iterationCounts, seed);
            HelperTestClass.TestDescriptorAssignment(descriptors.Length, clustering.Centroids[clustering.Centroids.Length - 1]);
        }
        public void VisualizeHeuristicDivisive3Layer()
        {
            int[] seedCounts      = new int[] { 10, 10, 10 };
            int[] iterationCounts = new int[] { 10, 10, 10 };

            ClusteringDivisive clustering = new ClusteringDivisive(descriptors);

            clustering.Clusterize(seedCounts, iterationCounts, seed);
            HelperTestClass.VisualizeClustering(clustering.Descriptors, clustering.Centroids, windowSize, windowSize);
        }