def __init__(self, masteruri, ns='/', parent=None): ''' @param masteruri: if the master uri is not None, the parameter are retrieved from ROS parameter server. @type masteruri: C{str} @param ns: namespace of the parameter retrieved from the ROS parameter server. @type ns: C{str} ''' ParameterDialog.__init__(self, dict(), parent=parent) self.masteruri = masteruri self.ns = ns self.is_delivered = False self.is_send = False self.mIcon = QtGui.QIcon(":/icons/default_cfg.png") self.setWindowIcon(self.mIcon) self.resize(450, 300) self.add_new_button = QtGui.QPushButton(self.tr("&Add")) self.add_new_button.clicked.connect(self._on_add_parameter) self.buttonBox.addButton(self.add_new_button, QtGui.QDialogButtonBox.ActionRole) # self.apply_button = QtGui.QPushButton(self.tr("&Ok")) # self.apply_button.clicked.connect(self._on_apply) # self.buttonBox.addButton(self.apply_button, QtGui.QDialogButtonBox.ApplyRole) # self.buttonBox.accepted.connect(self._on_apply) self.setText(' '.join([ 'Obtaining parameters from the parameter server', masteruri, '...' ])) self.parameterHandler = ParameterHandler() self.parameterHandler.parameter_list_signal.connect( self._on_param_list) self.parameterHandler.parameter_values_signal.connect( self._on_param_values) self.parameterHandler.delivery_result_signal.connect( self._on_delivered_values) self.parameterHandler.requestParameterList(masteruri, ns)
class MasterParameterDialog(ParameterDialog): ''' This dialog is an extension to the L{ParameterDialog}. The parameter and their values are requested from the ROS master parameter server. The requests are threaded and allows the also threaded changed of ROS parameter assigned to given namespace. ''' def __init__(self, masteruri, ns='/', parent=None): ''' @param masteruri: if the master uri is not None, the parameter are retrieved from ROS parameter server. @type masteruri: C{str} @param ns: namespace of the parameter retrieved from the ROS parameter server. @type ns: C{str} ''' ParameterDialog.__init__(self, dict(), parent=parent) self.masteruri = masteruri self.ns = ns self.is_delivered = False self.is_send = False self.mIcon = QtGui.QIcon(":/icons/default_cfg.png") self.setWindowIcon(self.mIcon) self.resize(450,300) self.add_new_button = QtGui.QPushButton(self.tr("&Add")) self.add_new_button.clicked.connect(self._on_add_parameter) self.buttonBox.addButton(self.add_new_button, QtGui.QDialogButtonBox.ActionRole) # self.apply_button = QtGui.QPushButton(self.tr("&Ok")) # self.apply_button.clicked.connect(self._on_apply) # self.buttonBox.addButton(self.apply_button, QtGui.QDialogButtonBox.ApplyRole) # self.buttonBox.accepted.connect(self._on_apply) self.setText(' '.join(['Obtaining parameters from the parameter server', masteruri, '...'])) self.parameterHandler = ParameterHandler() self.parameterHandler.parameter_list_signal.connect(self._on_param_list) self.parameterHandler.parameter_values_signal.connect(self._on_param_values) self.parameterHandler.delivery_result_signal.connect(self._on_delivered_values) self.parameterHandler.requestParameterList(masteruri, ns) # self.apply_button.setFocus(QtCore.Qt.OtherFocusReason) def accept(self): if not self.masteruri is None and not self.is_send: try: params = self.getKeywords() ros_params = dict() for p,v in params.items(): ros_params[roslib.names.ns_join(self.ns, p)] = v if ros_params: self.is_send = True self.setText('Send the parameter into server...') self.parameterHandler.deliverParameter(self.masteruri, ros_params) except Exception, e: QtGui.QMessageBox.warning(self, self.tr("Warning"), str(e), QtGui.QMessageBox.Ok) elif self.masteruri is None: QtGui.QMessageBox.warning(self, self.tr("Error"), 'Invalid ROS master URI', QtGui.QMessageBox.Ok)
def __init__(self, masteruri, ns='/', parent=None): ''' @param masteruri: if the master uri is not None, the parameter are retrieved from ROS parameter server. @type masteruri: C{str} @param ns: namespace of the parameter retrieved from the ROS parameter server. @type ns: C{str} ''' ParameterDialog.__init__(self, dict(), parent=parent) self.masteruri = masteruri self.ns = ns self.is_delivered = False self.is_send = False self.mIcon = QtGui.QIcon(":/icons/default_cfg.png") self.setWindowIcon(self.mIcon) self.resize(450,300) self.add_new_button = QtGui.QPushButton(self.tr("&Add")) self.add_new_button.clicked.connect(self._on_add_parameter) self.buttonBox.addButton(self.add_new_button, QtGui.QDialogButtonBox.ActionRole) # self.apply_button = QtGui.QPushButton(self.tr("&Ok")) # self.apply_button.clicked.connect(self._on_apply) # self.buttonBox.addButton(self.apply_button, QtGui.QDialogButtonBox.ApplyRole) # self.buttonBox.accepted.connect(self._on_apply) self.setText(' '.join(['Obtaining parameters from the parameter server', masteruri, '...'])) self.parameterHandler = ParameterHandler() self.parameterHandler.parameter_list_signal.connect(self._on_param_list) self.parameterHandler.parameter_values_signal.connect(self._on_param_values) self.parameterHandler.delivery_result_signal.connect(self._on_delivered_values) self.parameterHandler.requestParameterList(masteruri, ns)
config['nesterov'] = True config['momentum'] = 0.9 config['decay'] = 0.0 ######### EXPERIMENTAL PARAMETERS ############### hparam_map = {} hparam_map['supervised_mask_ratio'] = hp.HParam('supervised_mask_ratio', hp.Discrete([0.0])) hparam_map['unsupervised_mask_ratio'] = hp.HParam('unsupervised_mask_ratio', hp.Discrete([0.0])) hparam_map['mask_by'] = hp.HParam('mask_by', hp.Discrete(['example'])) hparam_map['dataset'] = hp.HParam('dataset', hp.Discrete(['cifar10central'])) hparam_map['batch_size'] = hp.HParam('batch_size', hp.Discrete([128])) hparam_map['learning_rate'] = hp.HParam('learning_rate', hp.Discrete([0.02])) ######### METRICS ############################### metric_map = {} metric_map['train_loss'] = hp.Metric('train_loss', display_name='Train Loss') metric_map['train_accuracy'] = hp.Metric('train_accuracy', display_name='Train Accuracy') metric_map['test_loss'] = hp.Metric('test_loss', display_name='Test Loss') metric_map['test_accuracy'] = hp.Metric('test_accuracy', display_name='Test Accuracy') ################################################# ph = ParameterHandler(config, hparam_map, metric_map) ph.hparam_sets = list(ph.gen_hparam_cartesian_product()) print(len(ph.hparam_sets))
HP_NUM_EPOCHS = hp.HParam('num_epochs', hp.Discrete([2])) hparam_map = { 'supervised_mask_ratio': HP_SUPERVISED_MASK_RATIO, 'unsupervised_mask_ratio': HP_UNSUPERVISED_MASK_RATIO, 'mask_by': HP_MASK_BY, 'dataset': HP_DATASET, 'learning_rate': HP_LEARNING_RATE, 'optimizer': HP_OPTIMIZER, 'batch_size': HP_BATCH_SIZE, 'num_clients_per_round': HP_NUM_CLIENTS_PER_ROUND, 'num_epochs': HP_NUM_EPOCHS } ######### METRICS ############################### METRIC_TRAIN_LOSS = hp.Metric('train_loss', display_name='Train Loss') METRIC_TRAIN_ACCURACY = hp.Metric('train_accuracy', display_name='Train Accuracy') METRIC_TEST_LOSS = hp.Metric('test_loss', display_name='Test Loss') METRIC_TEST_ACCURACY = hp.Metric('test_accuracy', display_name='Test Accuracy') metric_map = { 'train_loss': METRIC_TRAIN_LOSS, 'train_accuracy': METRIC_TRAIN_ACCURACY, 'test_loss': METRIC_TEST_LOSS, 'test_accuracy': METRIC_TEST_ACCURACY } ################################################# ph = ParameterHandler(config, hparam_map, metric_map)
class MasterParameterDialog(ParameterDialog): ''' This dialog is an extension to the L{ParameterDialog}. The parameter and their values are requested from the ROS master parameter server. The requests are threaded and allows the also threaded changed of ROS parameter assigned to given namespace. ''' def __init__(self, masteruri, ns='/', parent=None): ''' @param masteruri: if the master uri is not None, the parameter are retrieved from ROS parameter server. @type masteruri: C{str} @param ns: namespace of the parameter retrieved from the ROS parameter server. @type ns: C{str} ''' ParameterDialog.__init__(self, dict(), parent=parent) self.masteruri = masteruri self.ns = ns self.is_delivered = False self.is_send = False self.mIcon = QtGui.QIcon(":/icons/default_cfg.png") self.setWindowIcon(self.mIcon) self.resize(450, 300) self.add_new_button = QtGui.QPushButton(self.tr("&Add")) self.add_new_button.clicked.connect(self._on_add_parameter) self.buttonBox.addButton(self.add_new_button, QtGui.QDialogButtonBox.ActionRole) # self.apply_button = QtGui.QPushButton(self.tr("&Ok")) # self.apply_button.clicked.connect(self._on_apply) # self.buttonBox.addButton(self.apply_button, QtGui.QDialogButtonBox.ApplyRole) # self.buttonBox.accepted.connect(self._on_apply) self.setText(' '.join([ 'Obtaining parameters from the parameter server', masteruri, '...' ])) self.parameterHandler = ParameterHandler() self.parameterHandler.parameter_list_signal.connect( self._on_param_list) self.parameterHandler.parameter_values_signal.connect( self._on_param_values) self.parameterHandler.delivery_result_signal.connect( self._on_delivered_values) self.parameterHandler.requestParameterList(masteruri, ns) # self.apply_button.setFocus(QtCore.Qt.OtherFocusReason) def accept(self): if not self.masteruri is None and not self.is_send: try: params = self.getKeywords() ros_params = dict() for p, v in params.items(): ros_params[roslib.names.ns_join(self.ns, p)] = v if ros_params: self.is_send = True self.setText('Send the parameter into server...') self.parameterHandler.deliverParameter( self.masteruri, ros_params) except Exception, e: QtGui.QMessageBox.warning(self, self.tr("Warning"), str(e), QtGui.QMessageBox.Ok) elif self.masteruri is None: QtGui.QMessageBox.warning(self, self.tr("Error"), 'Invalid ROS master URI', QtGui.QMessageBox.Ok)