def __init__(self, activation=MA.Pass(), regularizations=[], initializations=[], learningScenari=[], decorators=[], name=None, maxInConnections=1, streams=["train", "test"]): super(Layer_ABC, self).__init__(initializations=[], streams=streams) self.maxInConnections = maxInConnections #a unique tag associated to the layer self.appelido = str(uuid.uuid1()) if name is not None: self.name = name else: self.name = "%s_%s" % (self.__class__.__name__, self.appelido) self.inputs = MTYPES.Variable(streams=self.streams) self.outputs = MTYPES.Variable(streams=self.streams) self.outputs_preactivation = None self.abstractions = { "activation": [activation], "regularizations": regularizations, "decorators": decorators, "initializations": initializations, "learningScenari": learningScenari, } self._inputRegistrations = set() self._resetNetwork()
def __init__(self, size, layerTypes, activation=MA.Pass(), regularizations=[], initializations=[], learningScenario=None, decorators=[], name=None): self.isLayer = True #a unique tag associated to the layer self.appelido = numpy.random.random() if name is not None: self.name = name else: self.name = "%s_%s" % (self.__class__.__name__, self.appelido) self.types = layerTypes self.nbInputs = None self.inputs = None self.nbOutputs = size self.outputs = None # this is a symbolic var self.testOutputs = None # this is a symbolic var self.preactivation_outputs = None self.preactivation_testOutputs = None self.activation = activation self.regularizationObjects = regularizations self.regularizations = [] self.decorators = decorators self.initializations = initializations self.learningScenario = learningScenario self.network = MNET.Network() self.network._addLayer(self) self._inputRegistrations = set() self._mustInit = True self._mustReset = True self._decorating = False self.parameters = {}
) c2 = MCONV.Convolution2D( nbFilters = 15, filterHeight = 3, filterWidth = 3, activation = MA.Max_norm(), pooler = maxPool, name = "conv2" ) fa = MCONV.Flatten(name="flata") fb = MCONV.Flatten(name="flatb") f = MCONV.Flatten(name = "flat") h = ML.Hidden(2048, activation = MA.Max_norm(), decorators = [MD.BinomialDropout(0.75)], regularizations = [], name = "hid" ) passa = ML.Hidden(1500, activation = MA.Pass(), decorators = [MD.BinomialDropout(0.5)], regularizations = [], name = "pass1" ) passb = ML.Hidden(1500, activation = MA.Pass(), decorators = [MD.BinomialDropout(0.5)], regularizations = [], name = "pass2" ) h2 = ML.Hidden(2048, activation = MA.Max_norm(), decorators = [MD.BinomialDropout(0.75)], regularizations = [], name = "hid2" ) o = ML.SoftmaxClassifier(2, decorators = [], learningScenario = ls, costObject = cost, name = "out", regularizations = [] ) model = i > c1 > c3 > c2 > f > h > h2 > o c1 > fa > passa > h > h2 > o c2 > fb > passb >h > h2 > o tscore = [] vscore = [] tdata = load_data(trainfile) vdata = load_data(validfile) vdata = (center(vdata[0]),vdata[1]) test = load_data(testfile) test = center(test)