(self)
Generator that can be used to iterate over this dataset.

        Yields:
            tuples, tuples, first tuple contains image features and one hot input sentence
                            second tuple contains one hot target sentence and mask
                            corresponding to 1's up to where each sentence ends and
                            zeros elsewhere after.
Generator that can be used to iterate over this dataset.
Generator that can be used to iterate over this dataset .
def __iter__(self):
        """
        Generator that can be used to iterate over this dataset.

        Yields:
            tuples, tuples, first tuple contains image features and one hot input sentence
                            second tuple contains one hot target sentence and mask
                            corresponding to 1's up to where each sentence ends and
                            zeros elsewhere after.
        """

        shuf_idx = self.be.rng.permutation(len(self.X))
        self.X, self.y, self.images = (self.X[shuf_idx], self.y[shuf_idx], self.images[shuf_idx])
        self.sent_length = self.sent_length[shuf_idx]

        for batch_idx in xrange(self.nbatches):

            start = batch_idx * self.be.bsz
            end = (batch_idx + 1) * self.be.bsz

            # image_batch = self.images[start:end].T.astype(np.float32, order='C')
            self.dev_imageT.set(self.images[start:end])
            self.dev_image[:] = self.dev_imageT.T

            # X_batch = self.X[start:end].T.astype(np.float32, order='C')
            self.dev_lblT.set(self.X[start:end])
            self.dev_lbl[:] = self.dev_lblT.T
            self.dev_X[:] = self.be.onehot(self.dev_lblflat, axis=0)

            self.y_mask[:] = 1
            sent_lens = self.sent_length[start:end]
            self.y_mask[:, self.sent_ends > sent_lens[np.newaxis, :]] = 0
            self.dev_y_mask[:] = self.y_mask_reshape

            # y_batch = self.y[start:end].T.astype(np.float32, order='C')
            self.dev_y_lblT.set(self.y[start:end])
            self.dev_y_lbl[:] = self.dev_y_lblT.T
            self.dev_y[:] = self.be.onehot(self.dev_y_lblflat, axis=0)
            self.dev_y[:] = self.dev_y * self.dev_y_mask

            yield (self.dev_image, self.dev_X), (self.dev_y, self.dev_y_mask)
def __iter__ ( self ) : shuf_idx = self . be . rng . permutation ( len ( self . X ) ) self . X , self . y , self . images = ( self . X [ shuf_idx ] , self . y [ shuf_idx ] , self . images [ shuf_idx ] ) self . sent_length = self . sent_length [ shuf_idx ] for batch_idx in xrange ( self . nbatches ) : start = batch_idx * self . be . bsz end = ( batch_idx + 1 ) * self . be . bsz # image_batch = self.images[start:end].T.astype(np.float32, order='C') self . dev_imageT . set ( self . images [ start : end ] ) self . dev_image [ : ] = self . dev_imageT . T # X_batch = self.X[start:end].T.astype(np.float32, order='C') self . dev_lblT . set ( self . X [ start : end ] ) self . dev_lbl [ : ] = self . dev_lblT . T self . dev_X [ : ] = self . be . onehot ( self . dev_lblflat , axis = 0 ) self . y_mask [ : ] = 1 sent_lens = self . sent_length [ start : end ] self . y_mask [ : , self . sent_ends > sent_lens [ np . newaxis , : ] ] = 0 self . dev_y_mask [ : ] = self . y_mask_reshape # y_batch = self.y[start:end].T.astype(np.float32, order='C') self . dev_y_lblT . set ( self . y [ start : end ] ) self . dev_y_lbl [ : ] = self . dev_y_lblT . T self . dev_y [ : ] = self . be . onehot ( self . dev_y_lblflat , axis = 0 ) self . dev_y [ : ] = self . dev_y * self . dev_y_mask yield ( self . dev_image , self . dev_X ) , ( self . dev_y , self . dev_y_mask )