neuroprob/likelihoods.py
def nll(self, b, rates, l_rates, spikes, neuron, disper_param=None):
        """
        The negative log likelihood function. Note that if disper_param is not None, it will use those values for 
        the dispersion parameter rather than its own dispersion parameters.
        
        :param int b: batch index to evaluate
        :param torch.tensor rates: rates of shape (trial, neuron, time)
        :param torch.tensor l_rates: spikes*log(rates)
        :param torch.tensor spikes: spike counts of shape (trial, neuron, time)
        :param list neuron: list of neuron indices to evaluate
        :param torch.tensor disper_param: input for heteroscedastic NB likelihood of shape (trial, neuron, time), 
                                          otherwise uses fixed :math:`r_{inv}`
        :returns: NLL of shape (trial, time)
        :rtype: torch.tensor
        """
        if disper_param is None:
            r_ = 1./(self.r_inv.expand(1, self.neurons)[:, neuron, None] + 1e-6)
        else:
            r_ = 1./(disper_param + 1e-6)
        
        tfact, lfact = self.get_saved_factors(b, neuron, spikes) 
        lambd = rates*self.tbin
        fac_lgamma = (-torch.lgamma(r_+spikes) + torch.lgamma(r_))
        fac_power = ((spikes+r_)*torch.log(r_+lambd) - r_*torch.log(r_))
        
        nll = (-l_rates + fac_power + fac_lgamma - tfact + lfact)
        return nll.sum(1)

        The negative log likelihood function. Note that if disper_param is not None, it will use those values for 
        the dispersion parameter rather than its own dispersion parameters.
        
        :param int b: batch index to evaluate
        :param torch.tensor rates: rates of shape (trial, neuron, time)
        :param torch.tensor l_rates: spikes*log(rates)
        :param torch.tensor spikes: spike counts of shape (trial, neuron, time)
        :param list neuron: list of neuron indices to evaluate
        :param torch.tensor disper_param: input for heteroscedastic NB likelihood of shape (trial, neuron, time), 
                                          otherwise uses fixed :math:`r_{inv}`
        :returns: NLL of shape (trial, time)
        :rtype: torch.tensor
        
The negative log likelihood function. Note that if disper_param is not None, it will use those values for
the dispersion parameter rather than its own dispersion parameters.
The negative log likelihood function . Note that if disper_param is not None it will use those values for the dispersion parameter rather than its own dispersion parameters .
def nll(self, b, rates, l_rates, spikes, neuron, disper_param=None):
        if disper_param is None:
            r_ = 1./(self.r_inv.expand(1, self.neurons)[:, neuron, None] + 1e-6)
        else:
            r_ = 1./(disper_param + 1e-6)
        tfact, lfact = self.get_saved_factors(b, neuron, spikes) 
        lambd = rates*self.tbin
        fac_lgamma = (-torch.lgamma(r_+spikes) + torch.lgamma(r_))
        fac_power = ((spikes+r_)*torch.log(r_+lambd) - r_*torch.log(r_))
        nll = (-l_rates + fac_power + fac_lgamma - tfact + lfact)
        return nll.sum(1)
def nll ( self , b , rates , l_rates , spikes , neuron , disper_param = None ) : if disper_param is None : r_ = 1. / ( self . r_inv . expand ( 1 , self . neurons ) [ : , neuron , None ] + 1e-6 ) else : r_ = 1. / ( disper_param + 1e-6 ) tfact , lfact = self . get_saved_factors ( b , neuron , spikes ) lambd = rates * self . tbin fac_lgamma = ( - torch . lgamma ( r_ + spikes ) + torch . lgamma ( r_ ) ) fac_power = ( ( spikes + r_ ) * torch . log ( r_ + lambd ) - r_ * torch . log ( r_ ) ) nll = ( - l_rates + fac_power + fac_lgamma - tfact + lfact ) return nll . sum ( 1 )
The negative log likelihood function.
The negative log likelihood function .
"""
        The negative log likelihood function. Note that if disper_param is not None, it will use those values for 
        the dispersion parameter rather than its own dispersion parameters.
        
        :param int b: batch index to evaluate
        :param torch.tensor rates: rates of shape (trial, neuron, time)
        :param torch.tensor l_rates: spikes*log(rates)
        :param torch.tensor spikes: spike counts of shape (trial, neuron, time)
        :param list neuron: list of neuron indices to evaluate
        :param torch.tensor disper_param: input for heteroscedastic NB likelihood of shape (trial, neuron, time), 
                                          otherwise uses fixed :math:`r_{inv}`
        :returns: NLL of shape (trial, time)
        :rtype: torch.tensor
        """
NLL of shape (trial, time)
NLL of shape ( trial time )
torch.tensor
self
b
batch index to evaluate
batch index to evaluate
rates
rates of shape (trial, neuron, time)
rates of shape ( trial neuron time )
l_rates
None
spikes
spike counts of shape (trial, neuron, time)
spike counts of shape ( trial neuron time )
neuron
list of neuron indices to evaluate
list of neuron indices to evaluate
disper_param
input for heteroscedastic NB likelihood of shape (trial, neuron, time),
otherwise uses fixed :math:`r_{inv}`
input for heteroscedastic NB likelihood of shape ( trial neuron time ) otherwise uses fixed : math : ` r_ { inv } `