neuroprob/likelihoods.py
def objective(self, F_mu, F_var, XZ, b, neuron, samples=10, mode='MC'):
        """
        Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which 
        can be used to compute different likelihood objectives.
        The returned tensor will have sample dimension as MC over :math:`q(z)`, depending 
        on the evaluation mode will be MC or GH or exact over the likelihood samples. This 
        is all combined in to the same dimension to be summed over. The weights :math:`w_s` 
        are the quadrature weights or equal weights for MC, with appropriate normalization.
        
        :param int samples: number of MC samples or GH points (exact will ignore and give 1)
        
        :returns: negative likelihood term of shape (samples, timesteps), sample weights (samples, 1
        :rtype: tuple of torch.tensors
        """
        if mode == 'MC':
            h = self.mc_gen(F_mu, F_var, samples, neuron) # h has only observed neurons
            rates, l_rates, spikes = self.sample_helper(h, b, neuron, samples)
            ws = torch.tensor(1./rates.shape[0])
        elif mode == 'GH':
            h, ws = self.gh_gen(F_mu, F_var, samples, neuron)
            rates, l_rates, spikes = self.sample_helper(h, b, neuron, samples)
            ws = ws[:, None]
        else:
            raise NotImplementedError
            
        if self.dispersion_mapping is None:
            disper_param = None
        else: # MC sampling
            disper_param = self.eval_dispersion_mapping(XZ, samples, neuron)
        
        return self.nll(b, rates, l_rates, spikes, neuron, disper_param), ws

        Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which 
        can be used to compute different likelihood objectives.
        The returned tensor will have sample dimension as MC over :math:`q(z)`, depending 
        on the evaluation mode will be MC or GH or exact over the likelihood samples. This 
        is all combined in to the same dimension to be summed over. The weights :math:`w_s` 
        are the quadrature weights or equal weights for MC, with appropriate normalization.
        
        :param int samples: number of MC samples or GH points (exact will ignore and give 1)
        
        :returns: negative likelihood term of shape (samples, timesteps), sample weights (samples, 1
        :rtype: tuple of torch.tensors
        
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which
can be used to compute different likelihood objectives.
The returned tensor will have sample dimension as MC over :math:`q(z)`, depending
on the evaluation mode will be MC or GH or exact over the likelihood samples. This
is all combined in to the same dimension to be summed over. The weights :math:`w_s`
are the quadrature weights or equal weights for MC, with appropriate normalization.
Computes the terms for variational expectation : math : ` \ mathbb { E } _ { q ( f ) q ( z ) } [] ` which can be used to compute different likelihood objectives . The returned tensor will have sample dimension as MC over : math : ` q ( z ) ` depending on the evaluation mode will be MC or GH or exact over the likelihood samples . This is all combined in to the same dimension to be summed over . The weights : math : ` w_s ` are the quadrature weights or equal weights for MC with appropriate normalization .
def objective(self, F_mu, F_var, XZ, b, neuron, samples=10, mode='MC'):
        if mode == 'MC':
            h = self.mc_gen(F_mu, F_var, samples, neuron) 
            rates, l_rates, spikes = self.sample_helper(h, b, neuron, samples)
            ws = torch.tensor(1./rates.shape[0])
        elif mode == 'GH':
            h, ws = self.gh_gen(F_mu, F_var, samples, neuron)
            rates, l_rates, spikes = self.sample_helper(h, b, neuron, samples)
            ws = ws[:, None]
        else:
            raise NotImplementedError
        if self.dispersion_mapping is None:
            disper_param = None
        else: 
            disper_param = self.eval_dispersion_mapping(XZ, samples, neuron)
        return self.nll(b, rates, l_rates, spikes, neuron, disper_param), ws
def objective ( self , F_mu , F_var , XZ , b , neuron , samples = 10 , mode = 'MC' ) : if mode == 'MC' : h = self . mc_gen ( F_mu , F_var , samples , neuron ) rates , l_rates , spikes = self . sample_helper ( h , b , neuron , samples ) ws = torch . tensor ( 1. / rates . shape [ 0 ] ) elif mode == 'GH' : h , ws = self . gh_gen ( F_mu , F_var , samples , neuron ) rates , l_rates , spikes = self . sample_helper ( h , b , neuron , samples ) ws = ws [ : , None ] else : raise NotImplementedError if self . dispersion_mapping is None : disper_param = None else : disper_param = self . eval_dispersion_mapping ( XZ , samples , neuron ) return self . nll ( b , rates , l_rates , spikes , neuron , disper_param ) , ws
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which
can be used to compute different likelihood objectives.
Computes the terms for variational expectation : math : ` \ mathbb { E } _ { q ( f ) q ( z ) } [] ` which can be used to compute different likelihood objectives .
"""
        Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which 
        can be used to compute different likelihood objectives.
        The returned tensor will have sample dimension as MC over :math:`q(z)`, depending 
        on the evaluation mode will be MC or GH or exact over the likelihood samples. This 
        is all combined in to the same dimension to be summed over. The weights :math:`w_s` 
        are the quadrature weights or equal weights for MC, with appropriate normalization.
        
        :param int samples: number of MC samples or GH points (exact will ignore and give 1)
        
        :returns: negative likelihood term of shape (samples, timesteps), sample weights (samples, 1
        :rtype: tuple of torch.tensors
        """ # h has only observed neurons # MC sampling
negative likelihood term of shape (samples, timesteps), sample weights (samples, 1
negative likelihood term of shape ( samples timesteps ) sample weights ( samples 1
tuple of torch.tensors
self
F_mu
F_var
XZ
b
neuron
samples
number of MC samples or GH points (exact will ignore and give 1)
number of MC samples or GH points ( exact will ignore and give 1 )
mode