Beispiel #1
0
 private void btThreadWrite_Click(object sender, EventArgs e)
 {
     WorkerThread.RunWorkerAsync();
     for (int x = 0; x < 100; x++)
     {
         //Debug.WriteLine("Main: Debug Message " + x.ToString());
         Trace.WriteLine("Main: Trace Message " + x.ToString());
         System.Threading.Thread.Sleep(20);
         Application.DoEvents();
     }
 }
        private void BtnTrain_Click(object sender, EventArgs e)
        {
            LoadTrain();
            LoadTest();

            iterations = 200;
            batchSize  = 32;
            model      = new NeuralNet(new Adam(), new BinaryCrossEntropy(), new BinaryAccuacy());
            model.Add(new FullyConnected(7, 32, "relu"));
            model.Add(new FullyConnected(32, 32, "relu"));
            model.Add(new FullyConnected(32, 1, "sigmoid"));

            model.BatchEnd += Model_BatchEnd;

            WorkerThread.RunWorkerAsync();
        }
        private void BtnTrain_Click(object sender, EventArgs e)
        {
            LoadTrain();
            LoadTest();

            iterations = 100;
            batchSize  = 32;
            model      = new NeuralNet(new Adam(), new MeanSquaredError(), new MeanAbsoluteError());
            model.Add(new FullyConnected(13, 26, "relu"));
            model.Add(new FullyConnected(26, 13, "relu"));
            model.Add(new FullyConnected(13, 1));

            model.BatchEnd += Model_BatchEnd;

            WorkerThread.RunWorkerAsync();
        }
        private void BtnXORTest_Click(object sender, EventArgs e)
        {
            x = new NDArray(4, 2);
            x.Load(0, 0, 0, 1, 1, 0, 1, 1);

            y = new NDArray(4, 1);
            y.Load(0, 1, 1, 0);

            iterations = 750;
            batchSize  = 2;
            model      = new NeuralNet(new Adam(), new BinaryCrossEntropy(), new BinaryAccuacy());
            model.Add(new FullyConnected(2, 8, "relu"));
            model.Add(new FullyConnected(8, 4, "relu"));
            model.Add(new FullyConnected(4, 1, "sigmoid"));

            model.BatchEnd += Model_BatchEnd;

            WorkerThread.RunWorkerAsync();
        }
        void StartEndlessThread()
        {
            if (ComponentManager.PowerDown || m_Destroyed)
            {
                return;
            }
            buttonEndlessStart.Sensitive = false;
            buttonEndlessStop.Sensitive  = true;

            lock (mEndlessThreadSemaphore)
            {
                myThreadId++;
                String name        = String.Format("Endless {0}:{1}", myThreadHeader, myThreadId);
                String description = "Endless WorkerThread";
                Message(String.Format("Thread {0} started", name));
                mEndlessThread = new WorkerThread(name, description);
                mEndlessThread.WorkerSupportsCancellation = true;
                mEndlessThread.WorkerReportsProgress      = false;
                mEndlessThread.DoWork             += new DoWorkEventHandler(mThreadEndless_DoWork);
                mEndlessThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(mThreadEndless_RunWorkerCompleted);
                mEndlessThread.RunWorkerAsync(ThreadPriority.BelowNormal);
            }
        }
        void StartNewThread()
        {
            if (ComponentManager.PowerDown || m_Destroyed)
            {
                return;
            }

            buttonStartThread.Sensitive = false;
            lock (mWorkerThreadSemaphore)
            {
                myThreadId++;
                String name        = String.Format("{0}:{1}", myThreadHeader, myThreadId);
                String description = "Example how to use WorkerThread";
                Message(String.Format("Thread {0} started", name));
                mWorkerThread = new WorkerThread(name, description);
                mWorkerThread.WorkerSupportsCancellation = true;
                mWorkerThread.WorkerReportsProgress      = true;
                mWorkerThread.DoWork             += new DoWorkEventHandler(mWorkerThread_DoWork);
                mWorkerThread.ProgressChanged    += new ProgressChangedEventHandler(mWorkerThread_ProgressChanged);
                mWorkerThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(mWorkerThread_RunWorkerCompleted);
                mWorkerThread.RunWorkerAsync(ThreadPriority.BelowNormal);
            }
        }