'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.'

def initialize(self, dataset, cost=None):

    if self.initialized:
        return
    prev_input = dataset
    prev_input = self.layers.configure(prev_input)
    if (cost is not None):
        cost.initialize(prev_input)
        self.cost = cost
    self.layers.allocate()
    self.layers.allocate_deltas()
    self.initialized = True
