def create_model(self): self.X = [T.imatrix(('X_%d' %i)) for i in range(self.num_of_corpus)] self.X_input = T.concatenate([T.tanh(T.dot(basic.row_normalize(self.X[i]*self.idf), self.W[i])) for i in range(self.num_of_corpus)], axis=0) self.X_c_input = T.concatenate([T.tanh(T.dot(basic.row_normalize(self.X[i]*self.idf), self.W_c)) for i in range(self.num_of_corpus)], axis=0) self.X_all_input = T.concatenate([self.X_input, self.X_c_input], axis=0) self.y_input = T.concatenate([i*T.ones_like(self.X[i][:,0], dtype='int32') for i in range(self.num_of_corpus)]) self.z_input = T.concatenate([T.ones_like(self.X_input[:,0], dtype='int32'), T.zeros_like(self.X_c_input[:,0], dtype='int32')]) self.classifier = basic.MLP(self.rng, self.X_c_input, self.y_input, n_out=self.num_of_corpus) self.discriminator = basic.MLP(self.rng, self.X_all_input, self.z_input, n_hidden=10, n_out=2, L2_reg=0.01) self.generator = [self.W_c]
def create_model(self): self.X = [T.imatrix(('X_%d' % i)) for i in range(self.num_of_corpus)] self.X_input = T.concatenate([ (T.dot(basic.row_normalize(self.X[i] * self.idf), self.W) + self.b) for i in range(self.num_of_corpus) ], axis=0) self.generator = Generator(self.rng, self.theano_rng, self.batch_size, self.num_of_corpus) self.X_all_input = T.concatenate( [self.X_input, (T.dot(self.generator.output, self.W) + self.b)], axis=0) self.y_input = T.concatenate([ i * T.ones_like(self.X[i][:, 0], dtype='int32') for i in range(self.num_of_corpus) ]) self.g_label_input = T.concatenate([ (i + self.num_of_corpus) * T.ones_like( self.generator.output[:self.generator.batch_size_var, 0], dtype='int32') for i in range(self.num_of_corpus) ]) self.y_all_input = T.concatenate([self.y_input, self.g_label_input]) self.discriminator = basic.MLP(self.rng, self.X_all_input, self.y_all_input, n_out=2 * self.num_of_corpus) self.classifier = basic.MLP(self.rng, self.X_input, self.y_input, n_out=self.num_of_corpus)
def create_model(self): self.X = [T.imatrix(('X_%d' %i)) for i in range(self.num_of_corpus)] self.X_c_input = T.concatenate([T.tanh(T.dot(basic.row_normalize(self.X[i]*self.idf), self.W_c) + self.b_c) for i in range(self.num_of_corpus)], axis=0) self.y_input = T.concatenate([i*T.ones_like(self.X[i][:,0], dtype='int32') for i in range(self.num_of_corpus)]) self.classifier = basic.MLP(self.rng, self.X_c_input, self.y_input, n_out=self.num_of_corpus) self.classifier_params = self.classifier.params + [self.W_c, self.b_c]