neuroprob/base.py
def eval_rate(self, covariates, neuron, mode='mean', percentiles=[0.05, 0.95], n_samp=1000, trials=1):
        """
        Evaluate the rate of the model as function of input covariates.
        
        :param np.array covariates: input covariates to evaluate rate over with shape (dims, timesteps)
        :param list neuron: neuron indices over which to evaluate rate
        :param string mode: what to evaluate, `mean` gives posterior mean (ML/MAP models this is the point 
                            estimate equivalently), `posterior` gives the percentile lines, `tuning` gives 
                            individual tuning curve samples from the variational posterior
        :param list percentiles: which percentiles to evaluate in `posterior` mode in addition to the mean
        :param int n_samp: the number of MC samples to use for evaluating posterior statistics
        :returns: output rate to [neurons, steps] or [steps] depending on neuron array or scalar
        :rtype: np.array
        """
        if np.max(neuron) >= self.out_dims: # avoid illegal access
            raise ValueError('Accessing output dimensions beyond specified dimensions by model')
        if ((mode == 'mean') or (mode == 'posterior') or (mode == 'tuning')) is False:
            raise ValueError('Rate evaluation mode is not recognized')
        
        if self.covariance_type is None: # no variational uncertainty
            if mode != 'mean':
                raise ValueError('Mapping has no variational uncertainty, hence must evaluate in mean mode')
            with torch.no_grad(): # will set regressor_mode to True
                XZ = self.to_XZ(covariates, trials)
                F_mu, _ = self.compute_F(XZ)

            return self.f(F_mu[:, neuron, :]).data.cpu().numpy()
     
        samples = self._samples(covariates, neuron, n_samp, False, trials)
        mean = samples.mean(0).cpu()
        if mode == 'mean':
            return mean.numpy()
        elif mode == 'posterior':
            lower, upper = signal.percentiles_from_samples(samples.cpu().float(), percentiles)
            return lower.numpy(), mean.numpy(), upper.numpy()
        else:
            samples = self._samples(covariates, neuron, n_samp, True, trials)
            return samples.cpu().numpy()

        Evaluate the rate of the model as function of input covariates.
        
        :param np.array covariates: input covariates to evaluate rate over with shape (dims, timesteps)
        :param list neuron: neuron indices over which to evaluate rate
        :param string mode: what to evaluate, `mean` gives posterior mean (ML/MAP models this is the point 
                            estimate equivalently), `posterior` gives the percentile lines, `tuning` gives 
                            individual tuning curve samples from the variational posterior
        :param list percentiles: which percentiles to evaluate in `posterior` mode in addition to the mean
        :param int n_samp: the number of MC samples to use for evaluating posterior statistics
        :returns: output rate to [neurons, steps] or [steps] depending on neuron array or scalar
        :rtype: np.array
        
Evaluate the rate of the model as function of input covariates.
Evaluate the rate of the model as function of input covariates .
def eval_rate(self, covariates, neuron, mode='mean', percentiles=[0.05, 0.95], n_samp=1000, trials=1):
        if np.max(neuron) >= self.out_dims: 
            raise ValueError('Accessing output dimensions beyond specified dimensions by model')
        if ((mode == 'mean') or (mode == 'posterior') or (mode == 'tuning')) is False:
            raise ValueError('Rate evaluation mode is not recognized')
        if self.covariance_type is None: 
            if mode != 'mean':
                raise ValueError('Mapping has no variational uncertainty, hence must evaluate in mean mode')
            with torch.no_grad(): 
                XZ = self.to_XZ(covariates, trials)
                F_mu, _ = self.compute_F(XZ)
            return self.f(F_mu[:, neuron, :]).data.cpu().numpy()
        samples = self._samples(covariates, neuron, n_samp, False, trials)
        mean = samples.mean(0).cpu()
        if mode == 'mean':
            return mean.numpy()
        elif mode == 'posterior':
            lower, upper = signal.percentiles_from_samples(samples.cpu().float(), percentiles)
            return lower.numpy(), mean.numpy(), upper.numpy()
        else:
            samples = self._samples(covariates, neuron, n_samp, True, trials)
            return samples.cpu().numpy()
def eval_rate ( self , covariates , neuron , mode = 'mean' , percentiles = [ 0.05 , 0.95 ] , n_samp = 1000 , trials = 1 ) : if np . max ( neuron ) >= self . out_dims : raise ValueError ( 'Accessing output dimensions beyond specified dimensions by model' ) if ( ( mode == 'mean' ) or ( mode == 'posterior' ) or ( mode == 'tuning' ) ) is False : raise ValueError ( 'Rate evaluation mode is not recognized' ) if self . covariance_type is None : if mode != 'mean' : raise ValueError ( 'Mapping has no variational uncertainty, hence must evaluate in mean mode' ) with torch . no_grad ( ) : XZ = self . to_XZ ( covariates , trials ) F_mu , _ = self . compute_F ( XZ ) return self . f ( F_mu [ : , neuron , : ] ) . data . cpu ( ) . numpy ( ) samples = self . _samples ( covariates , neuron , n_samp , False , trials ) mean = samples . mean ( 0 ) . cpu ( ) if mode == 'mean' : return mean . numpy ( ) elif mode == 'posterior' : lower , upper = signal . percentiles_from_samples ( samples . cpu ( ) . float ( ) , percentiles ) return lower . numpy ( ) , mean . numpy ( ) , upper . numpy ( ) else : samples = self . _samples ( covariates , neuron , n_samp , True , trials ) return samples . cpu ( ) . numpy ( )
Evaluate the rate of the model as function of input covariates.
Evaluate the rate of the model as function of input covariates .
"""
        Evaluate the rate of the model as function of input covariates.
        
        :param np.array covariates: input covariates to evaluate rate over with shape (dims, timesteps)
        :param list neuron: neuron indices over which to evaluate rate
        :param string mode: what to evaluate, `mean` gives posterior mean (ML/MAP models this is the point 
                            estimate equivalently), `posterior` gives the percentile lines, `tuning` gives 
                            individual tuning curve samples from the variational posterior
        :param list percentiles: which percentiles to evaluate in `posterior` mode in addition to the mean
        :param int n_samp: the number of MC samples to use for evaluating posterior statistics
        :returns: output rate to [neurons, steps] or [steps] depending on neuron array or scalar
        :rtype: np.array
        """ # avoid illegal access # no variational uncertainty # will set regressor_mode to True
output rate to [neurons, steps] or [steps] depending on neuron array or scalar
output rate to [ neurons steps ] or [ steps ] depending on neuron array or scalar
np.array
self
covariates
input covariates to evaluate rate over with shape (dims, timesteps)
input covariates to evaluate rate over with shape ( dims timesteps )
neuron
neuron indices over which to evaluate rate
neuron indices over which to evaluate rate
mode
None
percentiles
which percentiles to evaluate in `posterior` mode in addition to the mean
which percentiles to evaluate in ` posterior ` mode in addition to the mean
n_samp
the number of MC samples to use for evaluating posterior statistics
the number of MC samples to use for evaluating posterior statistics
trials