Restores training state from a given model checkpoint.

        This will also sync the trial results to a new location
        if restoring on a different node.
498069
def restore(self, trial, checkpoint=None):
        
        if checkpoint is None or checkpoint.value is None:
            checkpoint = trial._checkpoint
        if checkpoint is None or checkpoint.value is None:
            return True
        if trial.runner is None:
            logger.error("Unable to restore - no runner.")
            self.set_status(trial, Trial.ERROR)
            return False
        try:
            value = checkpoint.value
            if checkpoint.storage == Checkpoint.MEMORY:
                assert type(value) != Checkpoint, type(value)
                trial.runner.restore_from_object.remote(value)
            else:
                worker_ip = ray.get(trial.runner.current_ip.remote())
                trial.sync_logger_to_new_location(worker_ip)
                with warn_if_slow("restore_from_disk"):
                    ray.get(trial.runner.restore.remote(value))
            trial.last_result = checkpoint.last_result
            return True
        except Exception:
            logger.exception("Error restoring runner for Trial %s.", trial)
            self.set_status(trial, Trial.ERROR)
            return False
1169457
def restore_model(cls, data):
    
    obj = cls()
    for field in data:
        setattr(obj, field, data[field][Field.VALUE])

    return obj
1189787
def load(self, train_info: TrainingInfo) -> (dict, dict):
        
        last_epoch = train_info.start_epoch_idx

        model_state = torch.load(self.checkpoint_filename(last_epoch))
        hidden_state = torch.load(self.checkpoint_hidden_filename(last_epoch))

        self.checkpoint_strategy.restore(hidden_state)
        train_info.restore(hidden_state)

        return model_state, hidden_state
1129658
def restore_state(self):
        """"""
        last_path = setting('directory', '', expected_type=str)
        self.output_directory.setText(last_path)
801071
def __restore_processing_state(self):
        

        steps, value, message, state = self.__processing_state

        self.Application_Progress_Status_processing.Processing_progressBar.setRange(0, steps)
        self.Application_Progress_Status_processing.Processing_progressBar.setValue(value)
        self.set_processing_message(message, warning=False)
        self.__is_processing = state
        state and self.Application_Progress_Status_processing.show()
788898
def _checkpoint_and_erase(self, trial):
        

        with warn_if_slow("save_to_disk"):
            trial._checkpoint.value = ray.get(trial.runner.save.remote())

        if len(trial.history) >= trial.keep_checkpoints_num:
            ray.get(trial.runner.delete_checkpoint.remote(trial.history[-1]))
            trial.history.pop()

        trial.history.insert(0, trial._checkpoint.value)
995213
void restoreAllInstances() {

		// instancesMngr() instead of this.instancesMngr (for unit tests).
		this.logger.fine( "Restoring all the instance states from the current target handlers." );
		for( ManagedApplication ma : this.applicationMngr.getManagedApplications()) {

			// Build a new snapshot on every loop
			List<TargetHandler> snapshot = this.defaultTargetHandlerResolver.getTargetHandlersSnapshot();
			for( TargetHandler targetHandler : snapshot )
				instancesMngr().restoreInstanceStates( ma, targetHandler );
		}
	}
792282
def reset(self):
        
        state = self.sample()
        if state is None:
            # None indicates that a normal env reset should occur
            return self.env.reset()
        else:
            if self.need_xml:
                # reset the simulation from the model if necessary
                state, xml = state
                self.env.reset_from_xml_string(xml)

            if isinstance(state, tuple):
                state = state[0]

            # force simulator state to one from the demo
            self.sim.set_state_from_flattened(state)
            self.sim.forward()

            return self.env._get_observation()
1330983
def on_train_end(self, **kwargs):
        ""

        if self.save_model:
            # Adapted from fast.ai "SaveModelCallback"
            if self.model_path.is_file():
                with self.model_path.open('rb') as model_file:
                    self.learn.load(model_file, purge=False)
                    print(f'Loaded best saved model from {self.model_path}')
17315
public synchronized void restoreFromCheckpoint(CheckpointInputStream input) throws IOException {
    LOG.info("Restoring rocksdb from checkpoint");
    long startNano = System.nanoTime();
    Preconditions.checkState(input.getType() == CheckpointType.ROCKS,
        "Unexpected checkpoint type in RocksStore: " + input.getType());
    stopDb();
    FileUtils.deletePathRecursively(mDbPath);
    TarUtils.readTarGz(Paths.get(mDbPath), input);
    try {
      createDb();
    } catch (RocksDBException e) {
      throw new IOException(e);
    }
    LOG.info("Restored rocksdb checkpoint in {}ms",
        (System.nanoTime() - startNano) / Constants.MS_NANO);
  }
1009662
def _reset_model(self, response):
        """"""

        # pylint: disable=no-member

        # Reset the model to the initial state
        self._provision_done = False    # Set back the provision flag
        self._changes.clear()           # Clear the changes

        # Process the raw data from the update response
        fields = self.process_raw_data(response)
        # Update the current model representation
        self._set_fields(fields)

        # Lock the current model
        self._provision_done = True
674150
def rolledback!(force_restore_state: false, should_run_callbacks: true) #:nodoc:
      if should_run_callbacks && trigger_transactional_callbacks?
        _run_rollback_callbacks
        _run_rollback_without_transaction_enrollment_callbacks
      end
    ensure
      restore_transaction_record_state(force_restore_state)
      clear_transaction_record_state
    end
226238
def train_model(model_folder):
    """"""
    os.chdir(model_folder)
    training = generate_training_command(model_folder)
    if training is None:
        return -1
    logging.info(training)
    os.chdir(model_folder)
    os.system(training)
856713
def restore(self, state):
        


        selector = DataStreamSelector.FromString(state.get(u'selector'))
        if self.selector != selector:
            raise ArgumentError("Attempted to restore an InvalidStreamWalker with a different selector",
                                selector=self.selector, serialized_data=state)

        if state.get(u'type') != u'invalid':
            raise ArgumentError("Invalid serialized state for InvalidStreamWalker", serialized_data=state)
1197686
public void checkPoint(ValidationData param, ValidationRule rule, Object bodyObj, Object standardValue) {
        //check
        Object value = param.getValue(bodyObj);
        BaseValidationCheck checker = this.validationRuleStore.getValidationChecker(rule);
        if ((value != null && standardValue != null) || rule.getAssistType().isNullable()) {
            boolean valid = checker.check(value, standardValue);

            if (!valid) {
                this.callExcpetion(param, rule, value, standardValue);
            }

        }
        //replace value
        Object replaceValue = checker.replace(value, standardValue, param);
        if (replaceValue != null && replaceValue != value) {
            param.replaceValue(bodyObj, replaceValue);
        }
    }
340256
def restore_checkpoint(ckpt_dir, saver, sess, must_restore=False):
  """"""
  ckpt = tf.train.get_checkpoint_state(ckpt_dir)
  if must_restore and not ckpt:
    raise ValueError("No checkpoint found in %s" % ckpt_dir)
  if not ckpt:
    return 0

  path = ckpt.model_checkpoint_path
  tf.logging.info("Restoring checkpoint %s", path)
  saver.restore(sess, path)
  step = int(path.split("-")[-1])
  return step
1192916
def train(X_train, X_test, y_train, y_test, **kwargs):
    '''
    
    '''
    crf = Trainer()
    crf.set_params({
        'c1': 1.0,
        'c2': 0.001,
        'max_iterations': 200,
    })

    for xseq, yseq in zip(X_train, y_train):
        crf.append(xseq, yseq)
    crf.train(model_name)
    return crf