def __init__(self, conf, name=None): '''Listener constructor Args: conf: the encoder configuration name: the encoder name''' super(HotstartEncoder, self).__init__(conf, name) #set the wrapped section as the encoder section conf.remove_section('encoder') conf.add_section('encoder') for option, value in conf.items(self.conf['wrapped']): conf.set('encoder', option, value) conf.remove_section(self.conf['wrapped']) #wrapped ecoder self.wrapped = ed_encoder_factory.factory( conf.get('encoder', 'encoder'))(conf, self.conf['wrapped'])
def __init__(self, conf, constraint, name=None): '''constructor Args: conf: the encoder configuration name: the encoder name constraint: the constraint for the variables ''' super(BottleneckEncoder, self).__init__(conf, constraint, name) #set the wrapped section as the encoder section conf.remove_section('encoder') conf.add_section('encoder') for option, value in conf.items(self.conf['wrapped']): conf.set('encoder', option, value) conf.remove_section(self.conf['wrapped']) #wrapped ecoder self.wrapped = ed_encoder_factory.factory( conf.get('encoder', 'encoder'))(conf, constraint, self.conf['wrapped'])
def __init__(self, conf, constraint, name=None): '''constructor Args: conf: the encoder configuration name: the encoder name constraint: the constraint for the variables ''' super(StackEncoder, self).__init__(conf, constraint, name) #create the encoders self.encoders = [] for encoder in self.conf['stack'].split(): # Create a deep copy of the conf config_string = StringIO.StringIO() conf.write(config_string) # We must reset the buffer to make it ready for reading. config_string.seek(0) encoder_conf = ConfigParser.ConfigParser() encoder_conf.readfp(config_string) encoder_conf.remove_section('encoder') encoder_conf.add_section('encoder') #set the wrapped section as the trainer section for option, value in conf.items(encoder): encoder_conf.set('encoder', option, value) #remove the other encoder sections for remove in self.conf['stack'].split(): encoder_conf.remove_section(remove) self.encoders.append( ed_encoder_factory.factory( encoder_conf.get('encoder', 'encoder'))(encoder_conf, constraint, encoder))