/**
 *
 * Set trainingMode active and start the training.
 *
 */
void brain::setTrainingModeActive(){
    predictionModeActive = false;
    trainingModeActive = true;
    startTraining();
}
Beispiel #2
0
MainWindow::MainWindow( QWidget *parent, Qt::WindowFlags flags )
    : QMainWindow( parent, flags ), Ui::MainWindow()
{
  setupUi( this );

  /* QActionGroup for exclusive QAction */
  m_modalityGroup = new QActionGroup( this );
  m_modalityGroup->addAction( actionDesign_View );
  m_modalityGroup->addAction( actionTrain_View );
  m_modalityGroup->addAction( actionTest_View );

  /* Main QStackedWidget */
  m_stackedWidget = new MainStackedWidget( centralwidget );
  vboxLayout->addWidget( m_stackedWidget );

  /* NetworkManager */
  m_netManager = new NetworkManager( m_stackedWidget->graphWidget() );

  /* ToolBar for train view */
  m_trainToolBar = new QToolBar( this );
  m_trainToolBar->setOrientation( Qt::Horizontal );
  m_trainToolBar->setWindowTitle( tr( "Train Bar" ) );
  m_trainToolBar->addAction( actionStart_Train );
  m_trainToolBar->addAction( actionStop_Train );
  m_trainToolBar->setVisible( false );
  addToolBar( Qt::TopToolBarArea, m_trainToolBar );

  /* ToolBar for test view */
  m_testToolBar = new QToolBar( this );
  m_testToolBar->setOrientation( Qt::Horizontal );
  m_testToolBar->setWindowTitle( tr( "Test Bar" ) );
  m_testToolBar->addAction( actionTest_Network );
  m_testToolBar->setVisible( false );
  addToolBar( Qt::TopToolBarArea, m_testToolBar );

  /* QDockWidget for choosing input data */
  m_inputDock = new QDockWidget( tr( "Input Data" ), this );
  QWidget *tmpWidget = new QWidget( m_inputDock );

  QWidget *tmpDataWidget = new QWidget( tmpWidget );
  m_inputDockLayout = new QVBoxLayout( tmpDataWidget );

  QVBoxLayout *inputDockLayout =  new QVBoxLayout( tmpWidget );
  QPushButton *button = new QPushButton( tr("Edit Data Group"), tmpWidget );
  button->setEnabled( false );
  inputDockLayout->addWidget( button );
  inputDockLayout->addWidget( tmpDataWidget );
  inputDockLayout->addItem( new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ) );

  m_inputDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
  m_inputDock->setWidget( tmpWidget );
  m_inputDock->setVisible( false );
  addDockWidget( Qt::LeftDockWidgetArea, m_inputDock );

  /* QDockWidget for choosing train parameters */
  m_trainDock = new QDockWidget( tr( "Train Parameters" ), this );
  m_trainPropertyWidget = new TrainPropertyWidget( m_trainDock );
  m_trainDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
  m_trainDock->setWidget( m_trainPropertyWidget );
  m_trainDock->setVisible( false );
  addDockWidget( Qt::RightDockWidgetArea, m_trainDock );

  /* QDockWidget for choosing output property */
//   m_outputDock = new QDockWidget( tr( "Output Property" ), this );
//   m_outputPropertyWidget = new OutputPropertyWidget( m_outputDock );
//   m_outputDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
//   m_outputDock->setWidget( m_outputPropertyWidget );
//   m_outputDock->setVisible( false );
//   addDockWidget( Qt::RightDockWidgetArea, m_outputDock );

  /* QDockWidget for editing neurons property */
  m_propertyDock = new QDockWidget( tr( "Neuron Parameters" ), this );
  m_neuronPropertyWidget = new NeuronPropertyWidget( m_propertyDock );
  m_propertyDock->setAllowedAreas( Qt::AllDockWidgetAreas );
  m_propertyDock->setVisible( false );
  m_propertyDock->setWidget( m_neuronPropertyWidget );
  addDockWidget( Qt::RightDockWidgetArea, m_propertyDock );

  /* Populate View Menu */
  menuView->addAction( m_inputDock->toggleViewAction() );
  menuView->addAction( m_trainDock->toggleViewAction() );
//   menuView->addAction( m_outputDock->toggleViewAction() );
  menuView->addAction( m_propertyDock->toggleViewAction() );

  /* Pre-check some actions */
  m_propertyDock->toggleViewAction()->activate( QAction::Trigger );
  trainViewStatus << m_trainDock->toggleViewAction();

  /* Set connections */
  connect( m_netManager, SIGNAL( neuronSelectionChanged( DS::Neuron * ) ), m_neuronPropertyWidget, SLOT( updateValues( DS::Neuron * ) ) );
  connect( m_netManager, SIGNAL( neuronTypeChanged( DS::Neuron * ) ), m_neuronPropertyWidget, SLOT( updateValues( DS::Neuron * ) ) );
  connect( m_netManager, SIGNAL( trainingParametersChanged( DS::TrainingParameters * ) ), m_trainPropertyWidget, SLOT( updateValues( DS::TrainingParameters * ) ) );
  connect( m_netManager, SIGNAL( epochTrained( DS::Network::TrainEpochValues ) ), m_stackedWidget->trainWidget(), SLOT( updateTrainEpochValues( DS::Network::TrainEpochValues ) ) );
  connect( m_netManager, SIGNAL( trainDataChanged( DS::TrainData * ) ), m_stackedWidget->testWidget(), SLOT( changeTrainData( DS::TrainData * ) ) );
  connect( m_netManager, SIGNAL( networkTested( DS::Network::TestNetworkValues ) ), m_stackedWidget->testWidget(), SLOT( showNetworkTest( DS::Network::TestNetworkValues ) ) );
  connect( m_netManager, SIGNAL( trainStopped() ), this, SLOT( on_actionStop_Train_triggered() ) );
  connect( m_netManager, SIGNAL( trainFinished() ), this, SLOT( on_actionStop_Train_triggered() ) );
  connect( m_neuronPropertyWidget, SIGNAL( changeNeuronTypeRequested( DS::Neuron *, const QString & ) ), m_netManager, SLOT( changeNeuronType( DS::Neuron *, const QString & ) ) );
  connect( actionStart_Train, SIGNAL( triggered() ), m_netManager, SLOT( startTraining() ) );
  connect( actionStop_Train, SIGNAL( triggered() ), m_netManager, SLOT( stopTraining() ) );
  connect( actionTest_Network, SIGNAL( triggered() ), m_netManager, SLOT( testNetwork() ) );
  connect( actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
  connect( actionAbout_Qt, SIGNAL( triggered() ), qApp, SLOT( aboutQt() ) );
}