예제 #1
0
 def load(filename):
     self = AttentionalTranslationModel()
     with ModelFile(filename) as fp:
         self.__src_vocab = Vocabulary.load(fp.get_file_pointer())
         self.__trg_vocab = Vocabulary.load(fp.get_file_pointer())
         self.__n_embed = int(fp.read())
         self.__n_hidden = int(fp.read())
         self.__make_model()
         wrapper.begin_model_access(self.__model)
         fp.read_embed(self.__model.w_xi)
         fp.read_linear(self.__model.w_ia)
         fp.read_linear(self.__model.w_aa)
         fp.read_linear(self.__model.w_ib)
         fp.read_linear(self.__model.w_bb)
         fp.read_linear(self.__model.w_aw)
         fp.read_linear(self.__model.w_bw)
         fp.read_linear(self.__model.w_pw)
         fp.read_linear(self.__model.w_we)
         fp.read_linear(self.__model.w_ap)
         fp.read_linear(self.__model.w_bp)
         fp.read_embed(self.__model.w_yp)
         fp.read_linear(self.__model.w_pp)
         fp.read_linear(self.__model.w_cp)
         fp.read_linear(self.__model.w_dp)
         fp.read_linear(self.__model.w_py)
         wrapper.end_model_access(self.__model)
     return self
예제 #2
0
 def load(filename):
     self = AttentionalTranslationModel()
     with ModelFile(filename) as fp:
         self.__src_vocab = Vocabulary.load(fp.get_file_pointer())
         self.__trg_vocab = Vocabulary.load(fp.get_file_pointer())
         self.__n_embed = int(fp.read())
         self.__n_hidden = int(fp.read())
         self.__make_model()
         wrapper.begin_model_access(self.__model)
         fp.read_embed(self.__model.w_xi)
         fp.read_linear(self.__model.w_ia)
         fp.read_linear(self.__model.w_aa)
         fp.read_linear(self.__model.w_ib)
         fp.read_linear(self.__model.w_bb)
         fp.read_linear(self.__model.w_aw)
         fp.read_linear(self.__model.w_bw)
         fp.read_linear(self.__model.w_pw)
         fp.read_linear(self.__model.w_we)
         fp.read_linear(self.__model.w_ap)
         fp.read_linear(self.__model.w_bp)
         fp.read_embed(self.__model.w_yp)
         fp.read_linear(self.__model.w_pp)
         fp.read_linear(self.__model.w_cp)
         fp.read_linear(self.__model.w_dp)
         fp.read_linear(self.__model.w_py)
         wrapper.end_model_access(self.__model)
     return self
예제 #3
0
 def save(self, filename):
     with ModelFile(filename, 'w') as fp:
         self.__src_vocab.save(fp.get_file_pointer())
         self.__trg_vocab.save(fp.get_file_pointer())
         fp.write(self.__n_embed)
         fp.write(self.__n_hidden)
         wrapper.begin_model_access(self.__model)
         fp.write_embed(self.__model.w_xi)
         fp.write_linear(self.__model.w_ip)
         fp.write_linear(self.__model.w_pp)
         fp.write_linear(self.__model.w_pq)
         fp.write_linear(self.__model.w_qj)
         fp.write_linear(self.__model.w_jy)
         fp.write_embed(self.__model.w_yq)
         fp.write_linear(self.__model.w_qq)
         wrapper.end_model_access(self.__model)
예제 #4
0
 def save(self, filename):
     with ModelFile(filename, 'w') as fp:
         self.__src_vocab.save(fp.get_file_pointer())
         self.__trg_vocab.save(fp.get_file_pointer())
         fp.write(self.__n_embed)
         fp.write(self.__n_hidden)
         wrapper.begin_model_access(self.__model)
         fp.write_embed(self.__model.w_xi)
         fp.write_linear(self.__model.w_ip)
         fp.write_linear(self.__model.w_pp)
         fp.write_linear(self.__model.w_pq)
         fp.write_linear(self.__model.w_qj)
         fp.write_linear(self.__model.w_jy)
         fp.write_embed(self.__model.w_yq)
         fp.write_linear(self.__model.w_qq)
         wrapper.end_model_access(self.__model)
예제 #5
0
 def load(filename):
     self = EncoderDecoderModel()
     with ModelFile(filename) as fp:
         self.__src_vocab = Vocabulary.load(fp.get_file_pointer())
         self.__trg_vocab = Vocabulary.load(fp.get_file_pointer())
         self.__n_embed = int(fp.read())
         self.__n_hidden = int(fp.read())
         self.__make_model()
         wrapper.begin_model_access(self.__model)
         fp.read_embed(self.__model.w_xi)
         fp.read_linear(self.__model.w_ip)
         fp.read_linear(self.__model.w_pp)
         fp.read_linear(self.__model.w_pq)
         fp.read_linear(self.__model.w_qj)
         fp.read_linear(self.__model.w_jy)
         fp.read_embed(self.__model.w_yq)
         fp.read_linear(self.__model.w_qq)
         wrapper.end_model_access(self.__model)
     return self
예제 #6
0
 def load(filename):
     self = EncoderDecoderModel()
     with ModelFile(filename) as fp:
         self.__src_vocab = Vocabulary.load(fp.get_file_pointer())
         self.__trg_vocab = Vocabulary.load(fp.get_file_pointer())
         self.__n_embed = int(fp.read())
         self.__n_hidden = int(fp.read())
         self.__make_model()
         wrapper.begin_model_access(self.__model)
         fp.read_embed(self.__model.w_xi)
         fp.read_linear(self.__model.w_ip)
         fp.read_linear(self.__model.w_pp)
         fp.read_linear(self.__model.w_pq)
         fp.read_linear(self.__model.w_qj)
         fp.read_linear(self.__model.w_jy)
         fp.read_embed(self.__model.w_yq)
         fp.read_linear(self.__model.w_qq)
         wrapper.end_model_access(self.__model)
     return self
예제 #7
0
 def save(self, filename):
     with ModelFile(filename, 'w') as fp:
         self.__src_vocab.save(fp.get_file_pointer())
         self.__trg_vocab.save(fp.get_file_pointer())
         fp.write(self.__n_embed)
         fp.write(self.__n_hidden)
         wrapper.begin_model_access(self.__model)
         fp.write_embed(self.__model.w_xi)
         fp.write_linear(self.__model.w_ia)
         fp.write_linear(self.__model.w_aa)
         fp.write_linear(self.__model.w_ib)
         fp.write_linear(self.__model.w_bb)
         fp.write_linear(self.__model.w_aw)
         fp.write_linear(self.__model.w_bw)
         fp.write_linear(self.__model.w_pw)
         fp.write_linear(self.__model.w_we)
         fp.write_linear(self.__model.w_ap)
         fp.write_linear(self.__model.w_bp)
         fp.write_embed(self.__model.w_yp)
         fp.write_linear(self.__model.w_pp)
         fp.write_linear(self.__model.w_cp)
         fp.write_linear(self.__model.w_dp)
         fp.write_linear(self.__model.w_py)
         wrapper.end_model_access(self.__model)
예제 #8
0
 def save(self, filename):
     with ModelFile(filename, 'w') as fp:
         self.__src_vocab.save(fp.get_file_pointer())
         self.__trg_vocab.save(fp.get_file_pointer())
         fp.write(self.__n_embed)
         fp.write(self.__n_hidden)
         wrapper.begin_model_access(self.__model)
         fp.write_embed(self.__model.w_xi)
         fp.write_linear(self.__model.w_ia)
         fp.write_linear(self.__model.w_aa)
         fp.write_linear(self.__model.w_ib)
         fp.write_linear(self.__model.w_bb)
         fp.write_linear(self.__model.w_aw)
         fp.write_linear(self.__model.w_bw)
         fp.write_linear(self.__model.w_pw)
         fp.write_linear(self.__model.w_we)
         fp.write_linear(self.__model.w_ap)
         fp.write_linear(self.__model.w_bp)
         fp.write_embed(self.__model.w_yp)
         fp.write_linear(self.__model.w_pp)
         fp.write_linear(self.__model.w_cp)
         fp.write_linear(self.__model.w_dp)
         fp.write_linear(self.__model.w_py)
         wrapper.end_model_access(self.__model)