예제 #1
0
flag printReport(int lastReport, int update, unsigned long startTime) {
        unsigned long now, remaining;
        char buf[128];
        static unsigned int reportNum;
        static unsigned long last;
        static real perUpdate = 0.0;

        if (!lastReport) reportNum = 1;
        else reportNum++;

        if (Verbosity < 1) return TCL_OK;
        print(1, "%7d)  ", Net->totalUpdates);
        smartPrintReal(Net->error, 8, FALSE);
        print(1, "  ");
        smartPrintReal(Net->outputCost, 8, FALSE);
        print(1, "  ");
        smartPrintReal(Net->weightCost, 8, FALSE);
        print(1, "  ");
        smartPrintReal(Net->gradientLinearity, 8, FALSE);
        print(1, "  ");

        now = getTime();

        printTime((now - startTime) * 1e-3, buf);
        print(1, " %s   ", buf);
        if (Net->numUpdates > update && update != 0) {
                if (reportNum < 5)
                        perUpdate = (real) (now - startTime) / update;
                else
                        perUpdate = 0.5 * perUpdate + 0.5 * 
                                ((real) (now - last) / (update - lastReport));
                last = now;
                remaining = (unsigned long) (perUpdate * 1e-3 * 
                                (Net->numUpdates - update));
                printTime(remaining, buf);
        } else printTime(0, buf);
        print(1, "%s\n", buf);

        updateDisplays(ON_REPORT);
        return TCL_OK;
}
StateInfoWidget::StateInfoWidget(QWidget *parent):
    QWidget(parent)
{
    _automaton = nullptr;

    _numberDisplay = new QLabel(this);
    _numberLabel = new QLabel( "State number (quint16):", this);
    _nameDisplay = new QLabel(this);
    _nameLabel = new QLabel("State name:", this);
    _colorDisplay = new QLabel(this);
    _colorLabel = new QLabel("State display color RGB:" ,this);

    _layout = new QFormLayout(this);
    _layout->setLabelAlignment(Qt::AlignLeft);
    setLayout(_layout);
    _layout->addRow(_numberLabel, _numberDisplay);
    _layout->addRow(_nameLabel, _nameDisplay);
    _layout->addRow(_colorLabel, _colorDisplay);

    updateDisplays(0);
}
예제 #3
0
MapWindow::MapWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MapWindow)
{
  ui->setupUi(this);
  ui->actionPoly_Overlay->setChecked(settings.value("viewSettings/polyOverlay", false).toBool());
  ui->actionCursor->setChecked(settings.value("viewSettings/cursorVisible", true).toBool());
  quadList = new QList<Quad*>;

  outWin = new OutWindow();
  outWin->show();

  outWin->setQuadList(quadList);
  ui->widget->setQuadList(quadList);
  ui->widget->setOutputSize(outWin->getSize());
  quadDialog = new QuadConfigDialog();

  connect(outWin, SIGNAL(outputSizeChanged(QSize)), ui->widget, SLOT(outputResized(QSize)));
  connect(ui->widget, SIGNAL(updateDisplays()), outWin, SLOT(updateDisplay()));
  connect(this, SIGNAL(updateAllDisplays()), outWin, SLOT(updateDisplay()));
  connect(this, SIGNAL(updateAllDisplays()), ui->widget, SLOT(updateDisplay()));
  connect(ui->widget, SIGNAL(mouseMove(QPoint)), outWin, SLOT(MapMouseMoved(QPoint)));
  connect(quadDialog, SIGNAL(accepted()), this, SLOT(configureQuadAccepted()));
}
void StateInfoWidget::setAutomaton(Scripting::CellularAutomaton *automaton)
{
    _automaton = automaton;
    updateDisplays(0);
}
예제 #5
0
/* Assumes there is a net */
flag standardNetTrain(void) {
        int i, lastReport, batchesAtCriterion;
        flag willReport, groupCritReached, value = TCL_OK, done;
        unsigned long startTime;
        Algorithm A;

        if (Net->numUpdates < 0)
                return warning("numUpdates (%d) must be positive.", Net->numUpdates);
        if (Net->numUpdates == 0) return result("");
        if (!Net->trainingSet)
                return warning("There is no training set.");
        if (Net->learningRate < 0.0)
                return warning("learningRate (%f) cannot be negative.", Net->learningRate);
        if (Net->momentum < 0.0 && Net->momentum >= 1.0)
                return warning("momentum (%f) is out of range [0,1).", Net->momentum);
        if (Net->weightDecay < 0.0 || Net->weightDecay > 1.0)
                return warning("weightDecay (%f) must be in the range [0,1].",
                                Net->weightDecay);
        if (Net->reportInterval < 0)
                return warning("reportInterval (%d) cannot be negative.", 
                                Net->reportInterval);

        A = getAlgorithm(Net->algorithm);

        print(1, "Performing %d updates using %s...\n", 
                        Net->numUpdates, A->longName);
        if (Net->reportInterval) printReportHeader();

        startTime = getTime();
        lastReport = batchesAtCriterion = 0;
        groupCritReached = FALSE;
        done = FALSE;
        /* It always does at least one update. */
        for (i = 1; !done; i++) {
                RUN_PROC(preEpochProc);

                if ((value = Net->netTrainBatch(&groupCritReached))) break;

                if (Net->error < Net->criterion || groupCritReached)
                        batchesAtCriterion++;
                else batchesAtCriterion = 0;
                if ((Net->minCritBatches > 0 && batchesAtCriterion >= Net->minCritBatches)
                                || i >= Net->numUpdates) done = TRUE;

                willReport = (Net->reportInterval && 
                                ((i % Net->reportInterval == 0) || done))
                        ? TRUE : FALSE;

                RUN_PROC(postEpochProc);

                /* Here's the weight update (one epoch). */
                A->updateWeights(willReport); 

                RUN_PROC(postUpdateProc);

                updateDisplays(ON_UPDATE);

                Net->totalUpdates++;

                if (willReport) {
                        printReport(lastReport, i, startTime);
                        lastReport = i;
                }
                /* Stop if requested. */
                if (smartUpdate(FALSE)) break;
                /* Change the algorithm if requested. */
                if (A->code != Net->algorithm) {
                        A = getAlgorithm(Net->algorithm);
                        print(1, "Changing algorithm to %s...\n", A->longName);
                }
        }
        startTime = (getTime() - startTime);

        updateDisplays(ON_TRAINING);

        if (value == TCL_ERROR) return TCL_ERROR;
        result("Performed %d updates\n", i - 1);
        if (!done) {
                append("Training halted prematurely\n", i);
                value = TCL_ERROR;
        }
        if (Net->error <= Net->criterion && 
                        batchesAtCriterion >= Net->minCritBatches)
                append("Network reached overall error criterion of %f\n", 
                                Net->criterion);
        if (groupCritReached && batchesAtCriterion >= Net->minCritBatches)
                append("Network reached group output criterion\n");
        append("Total time elapsed: %.3f seconds", ((real) startTime * 1e-3));

        return value;
}
예제 #6
0
void MapWindow::updateDisplays()
{
  emit updateDisplays();
}
//SUPER EASY CONVENIENCE METHOD  
//Intended to be called once per loop() to keep scrolling and updating going
void mizraith_HDSP2111::GoDogGo(void) {
    automaticallyResetScrollFlagAndPositions();
    updateDisplays();
}