(self, dataset, cost=None)
Propagate shapes through the layers to configure, then allocate space.

        Arguments:
            dataset (NervanaDataIterator): Dataset iterator to perform initialization on
            cost (Cost): Defines the function which the model is minimizing based
                         on the output of the last layer and the input labels.
Propagate shapes through the layers to configure, then allocate space.
Propagate shapes through the layers to configure then allocate space .
def initialize(self, dataset, cost=None):
        """
        Propagate shapes through the layers to configure, then allocate space.

        Arguments:
            dataset (NervanaDataIterator): Dataset iterator to perform initialization on
            cost (Cost): Defines the function which the model is minimizing based
                         on the output of the last layer and the input labels.
        """
        if self.initialized:
            return

        # Propagate shapes through the layers to configure
        prev_input = self.layers.configure(self.noise_dim)

        if cost is not None:
            cost.initialize(prev_input)
            self.cost = cost

        # Now allocate space
        self.layers.generator.allocate(accumulate_updates=False)
        self.layers.discriminator.allocate(accumulate_updates=True)
        self.layers.allocate_deltas()
        self.initialized = True

        self.zbuf = self.be.iobuf(self.noise_dim)
        self.ybuf = self.be.iobuf((1,))
        self.z0 = self.be.iobuf(self.noise_dim)  # a fixed noise buffer for generating images
        self.fill_noise(self.z0, normal=(self.noise_type == 'normal'))
        self.cost_dis = np.empty((1,), dtype=np.float32)
        self.current_batch = self.gen_iter = self.last_gen_batch = 0
def initialize ( self , dataset , cost = None ) : if self . initialized : return # Propagate shapes through the layers to configure prev_input = self . layers . configure ( self . noise_dim ) if cost is not None : cost . initialize ( prev_input ) self . cost = cost # Now allocate space self . layers . generator . allocate ( accumulate_updates = False ) self . layers . discriminator . allocate ( accumulate_updates = True ) self . layers . allocate_deltas ( ) self . initialized = True self . zbuf = self . be . iobuf ( self . noise_dim ) self . ybuf = self . be . iobuf ( ( 1 , ) ) self . z0 = self . be . iobuf ( self . noise_dim ) # a fixed noise buffer for generating images self . fill_noise ( self . z0 , normal = ( self . noise_type == 'normal' ) ) self . cost_dis = np . empty ( ( 1 , ) , dtype = np . float32 ) self . current_batch = self . gen_iter = self . last_gen_batch = 0