コード例 #1
0
 def compile_model(self, *args, **kwargs):
     print '... building the model'
     d_names = [d['name'] for d in self.discriminator_ns]
     g_names = [d['name'] for d in self.generator_ns]
     assert len(set(d_names).intersection(g_names)) == 0, (
     'layer name cannot be the same for generator and discriminator network structure')
     
     total_structure = []
     total_structure.extend(self.generator_ns)
     total_structure.extend(self.discriminator_ns)
     self.name_index_dic = validate_network(total_structure)
     
     self.x = T.matrix('x')
     self.z = T.matrix('z')
     
     self.layers = obtain_network(self.batch_size,
                                  total_structure, 
                                  self.name_index_dic, self.init_params,
                                  check_output_usage=False)
     
     
     # this is to facilitate training
     sep_index = self.name_index_dic[self.discriminator_ns[0]['name']]
     self.gen_layers = self.layers[:sep_index]
     self.dis_layers = self.layers[sep_index:]
     self.gen_params = [l.params for l in self.gen_layers]
     self.dis_params = [l.params for l in self.dis_layers]
コード例 #2
0
ファイル: MLP.py プロジェクト: ybzhou/Gemini
    def compile_model(self, *args, **kwargs):
        print '... building the model'
        self.name_index_dic = validate_network(self.network_structure)
        
        self.layers = obtain_network(self.batch_size,
                                     self.network_structure, 
                                     self.name_index_dic, self.init_params)

        self.params = [l.params for l in self.layers]
コード例 #3
0
 def compile_model(self, *args, **kwargs):
     print '... building the model'
     data_dis_names = [d['name'] for d in self.data_discrim_ns]
     prior_dis_names = [d['name'] for d in self.prior_discrim_ns]
     enc_names = [d['name'] for d in self.encoder_ns]
     dec_names = [d['name'] for d in self.decoder_ns]
     assert len(set(prior_dis_names+data_dis_names+enc_names+dec_names)) == len(data_dis_names)+len(prior_dis_names) + len(enc_names) + len(dec_names), \
     'layer name cannot be the same for encoder, decoder and discriminator network structure'
     
     total_structure = []
     total_structure.extend(self.encoder_ns)
     total_structure.extend(self.decoder_ns)
     total_structure.extend(self.data_discrim_ns)
     total_structure.extend(self.prior_discrim_ns)
     self.name_index_dic = validate_network(total_structure)
     
     self.x = T.matrix('x')
     self.z = T.matrix('z')
     
     self.layers = obtain_network(self.batch_size,
                                  total_structure, 
                                  self.name_index_dic, self.init_params,
                                  check_output_usage=False)
     
     # encoder
     sep_index1 = self.name_index_dic[self.decoder_ns[0]['name']]
     self.enc_layers = self.layers[:sep_index1]
     # decoder
     sep_index2 = self.name_index_dic[self.data_discrim_ns[0]['name']]
     self.dec_layers = self.layers[sep_index1:sep_index2]
     # data discriminator
     sep_index3 = self.name_index_dic[self.prior_discrim_ns[0]['name']]
     self.data_dis_layers = self.layers[sep_index2:sep_index3]
     # prior discriminator
     self.prior_dis_layers = self.layers[sep_index3:]
     
     self.enc_params = [l.params for l in self.enc_layers]
     self.dec_params = [l.params for l in self.dec_layers]
     self.data_dis_params = [l.params for l in self.data_dis_layers]
     self.prior_dis_params = [l.params for l in self.prior_dis_layers]