(self, policy, condition, verbose=True, save=True, noisy=True)
Reset and execute a policy and collect a sample.
        Args:
            policy: A Policy object.
            condition: Which condition setup to run.
            verbose: Unused for this agent.
            save: Whether or not to store the trial into the samples.
            noisy: Whether or not to use noise during sampling.
        Returns:
            sample: A Sample object.
Reset and execute a policy and collect a sample.
        Args:
            policy: A Policy object.
            condition: Which condition setup to run.
            verbose: Unused for this agent.
            save: Whether or not to store the trial into the samples.
            noisy: Whether or not to use noise during sampling.
        Returns:
            sample: A Sample object.
Reset and execute a policy and collect a sample . Args : policy : A Policy object . condition : Which condition setup to run . verbose : Unused for this agent . save : Whether or not to store the trial into the samples . noisy : Whether or not to use noise during sampling . Returns : sample : A Sample object .
def sample(self, policy, condition, verbose=True, save=True, noisy=True):
        """
        Reset and execute a policy and collect a sample.
        Args:
            policy: A Policy object.
            condition: Which condition setup to run.
            verbose: Unused for this agent.
            save: Whether or not to store the trial into the samples.
            noisy: Whether or not to use noise during sampling.
        Returns:
            sample: A Sample object.
        """
        if TfPolicy is not None:  # user has tf installed.
            if isinstance(policy, TfPolicy):
                self._init_tf(policy.dU)

        self.reset(condition)
        # Generate noise.
        if noisy:
            noise = generate_noise(self.T, self.dU, self._hyperparams)
        else:
            noise = np.zeros((self.T, self.dU))

        # Execute trial.
        trial_command = TrialCommand()
        trial_command.id = self._get_next_seq_id()
        trial_command.controller = policy_to_msg(policy, noise)
        trial_command.T = self.T
        trial_command.id = self._get_next_seq_id()
        trial_command.frequency = self._hyperparams['frequency']
        ee_points = self._hyperparams['end_effector_points']
        trial_command.ee_points = ee_points.reshape(ee_points.size).tolist()
        trial_command.ee_points_tgt = \
                self._hyperparams['ee_points_tgt'][condition].tolist()
        trial_command.state_datatypes = self._hyperparams['state_include']
        trial_command.obs_datatypes = self._hyperparams['state_include']

        if self.use_tf is False:
            sample_msg = self._trial_service.publish_and_wait(
                trial_command, timeout=self._hyperparams['trial_timeout']
            )
            sample = msg_to_sample(sample_msg, self)
            if save:
                self._samples[condition].append(sample)
            return sample
        else:
            self._trial_service.publish(trial_command)
            sample_msg = self.run_trial_tf(policy, time_to_run=self._hyperparams['trial_timeout'])
            sample = msg_to_sample(sample_msg, self)
            if save:
                self._samples[condition].append(sample)
            return sample
def sample ( self , policy , condition , verbose = True , save = True , noisy = True ) : if TfPolicy is not None : # user has tf installed. if isinstance ( policy , TfPolicy ) : self . _init_tf ( policy . dU ) self . reset ( condition ) # Generate noise. if noisy : noise = generate_noise ( self . T , self . dU , self . _hyperparams ) else : noise = np . zeros ( ( self . T , self . dU ) ) # Execute trial. trial_command = TrialCommand ( ) trial_command . id = self . _get_next_seq_id ( ) trial_command . controller = policy_to_msg ( policy , noise ) trial_command . T = self . T trial_command . id = self . _get_next_seq_id ( ) trial_command . frequency = self . _hyperparams [ 'frequency' ] ee_points = self . _hyperparams [ 'end_effector_points' ] trial_command . ee_points = ee_points . reshape ( ee_points . size ) . tolist ( ) trial_command . ee_points_tgt = self . _hyperparams [ 'ee_points_tgt' ] [ condition ] . tolist ( ) trial_command . state_datatypes = self . _hyperparams [ 'state_include' ] trial_command . obs_datatypes = self . _hyperparams [ 'state_include' ] if self . use_tf is False : sample_msg = self . _trial_service . publish_and_wait ( trial_command , timeout = self . _hyperparams [ 'trial_timeout' ] ) sample = msg_to_sample ( sample_msg , self ) if save : self . _samples [ condition ] . append ( sample ) return sample else : self . _trial_service . publish ( trial_command ) sample_msg = self . run_trial_tf ( policy , time_to_run = self . _hyperparams [ 'trial_timeout' ] ) sample = msg_to_sample ( sample_msg , self ) if save : self . _samples [ condition ] . append ( sample ) return sample