Beispiel #1
0
    def __init__(self, layers: [base_layer.AbstractLayer]):
        """
        :parameter layers: a list of tuple for init layers
        """
        self.layers = layers
        self.weighted_layers = self.get_weighted_layers()
        self.rng = np.random.RandomState(1234)
        self.depth = len(self.weighted_layers)

        # set pickle file path
        self.file_name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
        self.pickle_file = conf.DATA_PATH + self.file_name + '.pkl'

        self.connect()
        # self.reset_params()
        self.init_weights_baises()
        self.weights, self.biases = self._get_weights_biases()

        # l1 and l2 regularization
        self.l1, self.l2 = self.init_regularization()

        # init my_theano functions
        self.x = T.matrix('x')
        self.y = T.ivector('y')
        self.index = T.iscalar('index')

        self.train_model = None
        self.valid_model = None
        self.test_model = None

        # set early stopping patience
        self.patience = 20
        self.patience_inc_coef = -0.1
        self.lest_valid_error = np.inf
Beispiel #2
0
    def __init__(self, layers, ceptron):
        """
        :parameter layers: a list of layers, by the type of base_layer
        """
        assert type(layers) == list
        self.layers = layers
        self.weights = self.init_weights()
        self.biases = self.init_biases()
        self.ceptron = ceptron
        self.depth = len(layers) - 1

        # init my_theano functions
        self.x = T.matrix('x')
        self.y = T.ivector('y')
        self.index = T.iscalar('index')
        self.p_y = self.forward(self.x)

        self.train_model = None
        # self.set_weights_biases = my_theano.function(self._make_updates(self.weights, self.biases))

        # set early stopping patience
        self.patience = 5
        self.patience_inc_coef = -0.1
        self.lest_valid_error = np.inf

        # set pickle file path
        self.file_name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
        self.pickle_file = conf.DATA_PATH + self.file_name + '.pkl'
Beispiel #3
0
    def __init__(self, layers: [base_layer.AbstractLayer]):
        """
        :parameter layers: a list of tuple for init layers
        """
        self.layers = layers
        self.rng = np.random.RandomState(1234)
        self.depth = len(self.layers) - 1

        self.weights = self.init_weights()
        self.biases = self.init_biases()

        # l1 and l2 regularization
        self.l1, self.l2 = self.init_regularization()

        # init my_theano functions
        self.x = T.matrix('x')
        self.y = T.ivector('y')
        self.index = T.iscalar('index')
        self.p_y = self.forward(self.x)

        self.train_model = None
        self.valid_model = None
        self.test_model = None
        # self.set_weights_biases = my_theano.function(self._make_updates(self.weights, self.biases))

        # set early stopping patience
        self.patience = 20
        self.patience_inc_coef = -0.1
        self.lest_valid_error = np.inf

        # set pickle file path
        self.file_name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
        self.pickle_file = conf.DATA_PATH + self.file_name + '.pkl'