def getTrainModel(self, data_x, data_y, data_sm): self.ngram_start_index = T.lscalar() self.ngram_end_index = T.lscalar() self.sm_start_index = T.lscalar() self.sm_end_index = T.lscalar() self.learning_rate = T.scalar() # TRAIN_MODEL self.train_outputs = [self.cost, self.grad_norm] self.train_set_x, self.train_set_y, self.train_set_sm = io_read_ngram.shared_dataset( [data_x, data_y, data_sm]) self.int_train_set_y = T.cast(self.train_set_y, 'int32') self.train_model = theano.function( inputs=[ self.ngram_start_index, self.ngram_end_index, self.sm_start_index, self.sm_end_index, self.learning_rate ], outputs=self.train_outputs, updates=self.updates, givens={ self.x: self.train_set_x[self.ngram_start_index:self.ngram_end_index], self.y: self.int_train_set_y[self.ngram_start_index:self. ngram_end_index], self.sm: self.train_set_sm[self.sm_start_index:self.sm_end_index], self.lr: self.learning_rate }) return self.train_model
def getTrainModel(self, data_x, data_y, data_sm): self.ngram_start_index = T.lscalar() self.ngram_end_index = T.lscalar() self.sm_start_index = T.lscalar() self.sm_end_index = T.lscalar() self.learning_rate = T.scalar() # TRAIN_MODEL self.train_outputs = [self.cost, self.grad_norm] self.train_set_x, self.train_set_y, self.train_set_sm = io_read_ngram.shared_dataset([data_x, data_y, data_sm]) self.int_train_set_y = T.cast(self.train_set_y, "int32") self.train_model = theano.function( inputs=[ self.ngram_start_index, self.ngram_end_index, self.sm_start_index, self.sm_end_index, self.learning_rate, ], outputs=self.train_outputs, updates=self.updates, givens={ self.x: self.train_set_x[self.ngram_start_index : self.ngram_end_index], self.y: self.int_train_set_y[self.ngram_start_index : self.ngram_end_index], self.sm: self.train_set_sm[self.sm_start_index : self.sm_end_index], self.lr: self.learning_rate, }, ) return self.train_model
def loadTestSet(self, test_data_package): self.test_set_x, self.test_set_y, self.test_set_sm = test_data_package self.shared_test_set_x, self.shared_test_set_y, self.shared_test_set_sm = io_read_ngram.shared_dataset(test_data_package) self.shared_test_set_y = T.cast(self.shared_test_set_y, 'int32') self.test_set_loaded = True
def loadValidSet(self, valid_data_package): self.valid_set_x, self.valid_set_y, self.valid_set_sm = valid_data_package self.shared_valid_set_x, self.shared_valid_set_y, self.shared_valid_set_sm = io_read_ngram.shared_dataset(valid_data_package) self.shared_valid_set_y = T.cast(self.shared_valid_set_y, 'int32') self.valid_set_loaded = True