tyxe/bnn.py
def fit(self, data_loader, num_samples, device=None, batch_data=False, **mcmc_kwargs):
        """Runs MCMC on the data from data loader using the kernel that was used to instantiate the class.

        :param data_loader: iterable or list of batched inputs to the net. If iterable treated like the data_loader
            of VariationalBNN and all network inputs are concatenated via torch.cat. Otherwise must be a tuple of
            a single or list of network inputs and a tensor for the targets.
        :param int num_samples: number of MCMC samples to draw.
        :param torch.device device: optional device to send the data to.
        :param batch_data: whether to treat data_loader as a full batch of data or an iterable over mini-batches.
        :param dict mcmc_kwargs: keyword arguments for initializing the pyro.infer.mcmc.MCMC object."""
        if batch_data:
            input_data, observation_data = data_loader
        else:
            input_data_lists = defaultdict(list)
            observation_data_list = []
            for in_data, obs_data in iter(data_loader):
                for i, data in enumerate(_as_tuple(in_data)):
                    input_data_lists[i].append(data.to(device))
                observation_data_list.append(obs_data.to(device))
            input_data = tuple(torch.cat(input_data_lists[i]) for i in range(len(input_data_lists)))
            observation_data = torch.cat(observation_data_list)
        self._mcmc = MCMC(self.kernel, num_samples, **mcmc_kwargs)
        self._mcmc.run(input_data, observation_data)

        return self._mcmc
Runs MCMC on the data from data loader using the kernel that was used to instantiate the class.

        :param data_loader: iterable or list of batched inputs to the net. If iterable treated like the data_loader
            of VariationalBNN and all network inputs are concatenated via torch.cat. Otherwise must be a tuple of
            a single or list of network inputs and a tensor for the targets.
        :param int num_samples: number of MCMC samples to draw.
        :param torch.device device: optional device to send the data to.
        :param batch_data: whether to treat data_loader as a full batch of data or an iterable over mini-batches.
        :param dict mcmc_kwargs: keyword arguments for initializing the pyro.infer.mcmc.MCMC object.
Runs MCMC on the data from data loader using the kernel that was used to instantiate the class.
Runs MCMC on the data from data loader using the kernel that was used to instantiate the class .
def fit(self, data_loader, num_samples, device=None, batch_data=False, **mcmc_kwargs):
        if batch_data:
            input_data, observation_data = data_loader
        else:
            input_data_lists = defaultdict(list)
            observation_data_list = []
            for in_data, obs_data in iter(data_loader):
                for i, data in enumerate(_as_tuple(in_data)):
                    input_data_lists[i].append(data.to(device))
                observation_data_list.append(obs_data.to(device))
            input_data = tuple(torch.cat(input_data_lists[i]) for i in range(len(input_data_lists)))
            observation_data = torch.cat(observation_data_list)
        self._mcmc = MCMC(self.kernel, num_samples, **mcmc_kwargs)
        self._mcmc.run(input_data, observation_data)
        return self._mcmc
def fit ( self , data_loader , num_samples , device = None , batch_data = False , ** mcmc_kwargs ) : if batch_data : input_data , observation_data = data_loader else : input_data_lists = defaultdict ( list ) observation_data_list = [ ] for in_data , obs_data in iter ( data_loader ) : for i , data in enumerate ( _as_tuple ( in_data ) ) : input_data_lists [ i ] . append ( data . to ( device ) ) observation_data_list . append ( obs_data . to ( device ) ) input_data = tuple ( torch . cat ( input_data_lists [ i ] ) for i in range ( len ( input_data_lists ) ) ) observation_data = torch . cat ( observation_data_list ) self . _mcmc = MCMC ( self . kernel , num_samples , ** mcmc_kwargs ) self . _mcmc . run ( input_data , observation_data ) return self . _mcmc
Runs MCMC on the data from data loader using the kernel that was used to instantiate the class.
Runs MCMC on the data from data loader using the kernel that was used to instantiate the class .
"""Runs MCMC on the data from data loader using the kernel that was used to instantiate the class.

        :param data_loader: iterable or list of batched inputs to the net. If iterable treated like the data_loader
            of VariationalBNN and all network inputs are concatenated via torch.cat. Otherwise must be a tuple of
            a single or list of network inputs and a tensor for the targets.
        :param int num_samples: number of MCMC samples to draw.
        :param torch.device device: optional device to send the data to.
        :param batch_data: whether to treat data_loader as a full batch of data or an iterable over mini-batches.
        :param dict mcmc_kwargs: keyword arguments for initializing the pyro.infer.mcmc.MCMC object."""
self
data_loader
iterable or list of batched inputs to the net. If iterable treated like the data_loader
of VariationalBNN and all network inputs are concatenated via torch.cat. Otherwise must be a tuple of
a single or list of network inputs and a tensor for the targets.
iterable or list of batched inputs to the net . If iterable treated like the data_loader of VariationalBNN and all network inputs are concatenated via torch . cat . Otherwise must be a tuple of a single or list of network inputs and a tensor for the targets .
num_samples
number of MCMC samples to draw.
number of MCMC samples to draw .
device
optional device to send the data to.
optional device to send the data to .
batch_data
whether to treat data_loader as a full batch of data or an iterable over mini-batches.
whether to treat data_loader as a full batch of data or an iterable over mini - batches .
mcmc_kwargs
keyword arguments for initializing the pyro.infer.mcmc.MCMC object.
keyword arguments for initializing the pyro . infer . mcmc . MCMC object .