Skip to content

Commit

Permalink
Merged with \'Iterator refactor\' branch sordonia#14, and added addti…
Browse files Browse the repository at this point in the history
…onal baclwards compatability and exception handling code.
  • Loading branch information
julianser committed May 21, 2015
1 parent 69a1fe5 commit ee0b988
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion dialog_encdec.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@ def init_params(self):
######################
# Output layer weights
######################
if self.maxout_out:
if int(self.qdim) != 2*int(self.rankdim):
raise ValueError('Error with maxout configuration in UtteranceDecoder!'
+ 'For maxout to work we need qdim = 2x rankdim')

out_target_dim = self.qdim
if not self.maxout_out:
out_target_dim = self.rankdim
Expand Down Expand Up @@ -1005,9 +1010,24 @@ def __init__(self, state):
self.global_params = []

# Compatibility towards older models
if not hasattr(state, 'dcgm_encoder'):
state['dcgm_encoder'] = False

if not hasattr(state, 'bootstrap_from_semantic_information'):
state['bootstrap_from_semantic_information'] = False

if not hasattr(state, 'bidirectional_utterance_encoder'):
state['bidirectional_utterance_encoder'] = False

if not hasattr(state, 'encode_with_l2_pooling'):
state['encode_with_l2_pooling'] = False

if not hasattr(state, 'direct_connection_between_encoders_and_decoder'):
state['direct_connection_between_encoders_and_decoder'] = False

self.__dict__.update(state)
self.rng = numpy.random.RandomState(state['seed'])

# Load dictionary
raw_dict = cPickle.load(open(self.dictionary, 'r'))

Expand Down Expand Up @@ -1080,6 +1100,7 @@ def __init__(self, state):
# Initialize word embeddings randomly
self.W_emb = add_to_params(self.global_params, theano.shared(value=NormalInit(self.rng, self.idim, self.rankdim), name='W_emb'))


# Build utterance encoders
if self.bidirectional_utterance_encoder:
assert not self.dcgm_encoder
Expand Down
1 change: 1 addition & 0 deletions state.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def prototype_state():
state['eos_sym'] = 2
state['sos_sym'] = 1

# Maxout requires qdim = 2x rankdim
state['maxout_out'] = False
state['deep_out'] = True
state['dcgm_encoder'] = False
Expand Down

0 comments on commit ee0b988

Please sign in to comment.