pytorch_generative/models/base.py
def sample(self, out_shape = None, conditioned_on = None):
        """Generates new samples from the model.

        Args:
            out_shape: The expected shape of the sampled output in NCHW format.  Should
                only be provided when 'conditioned_on=None'.
            conditioned_on: A batch of partial samples to condition the generation on.
                Only dimensions with values < 0 will be sampled while dimensions with
                values >= 0 will be left unchanged. If 'None', an unconditional sample
                will be generated.
        """
        with torch.no_grad():
            conditioned_on = self._get_conditioned_on(out_shape, conditioned_on)

            h, w = conditioned_on.shape
            n=1
            c=1
            conditioned_on = conditioned_on.long()


            for row in range(w): # w =1
                for col in range(h): # h = 1024

                    #

                    # conditioned_on = torch.Size([1024, 1])

                    out = self.forward(conditioned_on,sampleFlag = True)

                    # out.shape = torch.Size([1, 512, 1024])
                    # conditioned_on = torch.Size([1024, 1])

                    out = out[:,:,:,None]

                    # out.shape = torch.Size([1, 512, 1024, 1])
                    # conditioned_on = torch.Size([1024, 1])

                    out = out[:, :, col, row] # TODO : <==== Switch row (w) with col (h) or permute out tensor

                    # out.shape = torch.Size([1, 512])
                    # conditioned_on = torch.Size([1024, 1])

                    out = self._sample_fn(torch.exp(out)).view(n, c)

                    # out.shape = torch.Size([1, 1])
                    # conditioned_on = torch.Size([1024, 1])

                    conditioned_on[col, row] = torch.where(
                        conditioned_on[col, row] < 0,
                        out,
                        conditioned_on[col, row],

                    )

            return conditioned_on
Generates new samples from the model.

        Args:
            out_shape: The expected shape of the sampled output in NCHW format.  Should
                only be provided when 'conditioned_on=None'.
            conditioned_on: A batch of partial samples to condition the generation on.
                Only dimensions with values < 0 will be sampled while dimensions with
                values >= 0 will be left unchanged. If 'None', an unconditional sample
                will be generated.
        
Generates new samples from the model.
Generates new samples from the model .
def sample(self, out_shape = None, conditioned_on = None):
        with torch.no_grad():
            conditioned_on = self._get_conditioned_on(out_shape, conditioned_on)
            h, w = conditioned_on.shape
            n=1
            c=1
            conditioned_on = conditioned_on.long()
            for row in range(w): 
                for col in range(h): 
                     conditioned_on = torch.Size([1024, 1])
                    out = self.forward(conditioned_on,sampleFlag = True)
                     out.shape = torch.Size([1, 512, 1024])
                     conditioned_on = torch.Size([1024, 1])
                    out = out[:,:,:,None]
                     out.shape = torch.Size([1, 512, 1024, 1])
                     conditioned_on = torch.Size([1024, 1])
                    out = out[:, :, col, row]  TODO : <==== Switch row (w) with col (h) or permute out tensor
                     out.shape = torch.Size([1, 512])
                     conditioned_on = torch.Size([1024, 1])
                    out = self._sample_fn(torch.exp(out)).view(n, c)
                     out.shape = torch.Size([1, 1])
                     conditioned_on = torch.Size([1024, 1])
                    conditioned_on[col, row] = torch.where(
                        conditioned_on[col, row] < 0,
                        out,
                        conditioned_on[col, row],
                    )
            return conditioned_on
def sample ( self , out_shape = None , conditioned_on = None ) : with torch . no_grad ( ) : conditioned_on = self . _get_conditioned_on ( out_shape , conditioned_on ) h , w = conditioned_on . shape n = 1 c = 1 conditioned_on = conditioned_on . long ( ) for row in range ( w ) : for col in range ( h ) : out = self . forward ( conditioned_on , sampleFlag = True ) out = out [ : , : , : , None ] out = out [ : , : , col , row ] out = self . _sample_fn ( torch . exp ( out ) ) . view ( n , c ) conditioned_on [ col , row ] = torch . where ( conditioned_on [ col , row ] < 0 , out , conditioned_on [ col , row ] , ) return conditioned_on
Generates new samples from the model.
Generates new samples from the model .
"""Generates new samples from the model.

        Args:
            out_shape: The expected shape of the sampled output in NCHW format.  Should
                only be provided when 'conditioned_on=None'.
            conditioned_on: A batch of partial samples to condition the generation on.
                Only dimensions with values < 0 will be sampled while dimensions with
                values >= 0 will be left unchanged. If 'None', an unconditional sample
                will be generated.
        """ # w =1 # h = 1024 # # conditioned_on = torch.Size([1024, 1]) # out.shape = torch.Size([1, 512, 1024]) # conditioned_on = torch.Size([1024, 1]) # out.shape = torch.Size([1, 512, 1024, 1]) # conditioned_on = torch.Size([1024, 1]) # TODO : <==== Switch row (w) with col (h) or permute out tensor # out.shape = torch.Size([1, 512]) # conditioned_on = torch.Size([1024, 1]) # out.shape = torch.Size([1, 1]) # conditioned_on = torch.Size([1024, 1])
self
out_shape
The expected shape of the sampled output in NCHW format.  Should
only be provided when 'conditioned_on=None'.
The expected shape of the sampled output in NCHW format . Should only be provided when ' conditioned_on = None ' .
conditioned_on
A batch of partial samples to condition the generation on.
Only dimensions with values < 0 will be sampled while dimensions with
values >= 0 will be left unchanged. If 'None', an unconditional sample
will be generated.
A batch of partial samples to condition the generation on . Only dimensions with values < 0 will be sampled while dimensions with values > = 0 will be left unchanged . If ' None ' an unconditional sample will be generated .