示例#1
0
 def load(name, prefix):
     lstm = LSTM.__new__(LSTM)
     lstm.name_ = name
     lstm.pwxh_ = Parameter.load(prefix + name + "_wxh.param")
     lstm.pwhh_ = Parameter.load(prefix + name + "_whh.param")
     lstm.pbh_ = Parameter.load(prefix + name + "_bh.param")
     lstm.out_size_ = lstm.pbh_.shape()[0] / 4
     return lstm
示例#2
0
 def load(name, prefix):
     encdec = EncoderDecoder.__new__(EncoderDecoder)
     encdec.name_ = name
     encdec.psrc_lookup_ = Parameter.load(prefix + name +
                                          "_src_lookup.param")
     encdec.ptrg_lookup_ = Parameter.load(prefix + name +
                                          "_trg_lookup.param")
     encdec.pwhy_ = Parameter.load(prefix + name + "_why.param")
     encdec.pby_ = Parameter.load(prefix + name + "_by.param")
     encdec.src_lstm_ = LSTM.load(name + "_src_lstm", prefix)
     encdec.trg_lstm_ = LSTM.load(name + "_trg_lstm", prefix)
     with open(prefix + name + ".config", "r") as ifs:
         encdec.dropout_rate_ = float(ifs.readline())
     return encdec
示例#3
0
 def load(name, prefix):
     encdec = EncoderDecoder.__new__(EncoderDecoder)
     encdec.name_ = name
     encdec.psrc_lookup_ = Parameter.load(prefix + name +
                                          "_src_lookup.param")
     encdec.ptrg_lookup_ = Parameter.load(prefix + name +
                                          "_trg_lookup.param")
     encdec.pwhj_ = Parameter.load(prefix + name + "_whj.param")
     encdec.pbj_ = Parameter.load(prefix + name + "_bj.param")
     encdec.pwjy_ = Parameter.load(prefix + name + "_wjy.param")
     encdec.pby_ = Parameter.load(prefix + name + "_by.param")
     encdec.src_fw_lstm_ = LSTM.load(name + "_src_fw_lstm", prefix)
     encdec.src_bw_lstm_ = LSTM.load(name + "_src_bw_lstm", prefix)
     encdec.trg_lstm_ = LSTM.load(name + "_trg_lstm", prefix)
     encdec.embed_size_ = encdec.pbj_.shape()[0]
     with open(prefix + name + ".config", "r", encoding="utf-8") as f:
         encdec.dropout_rate_ = float(f.readline())
     return encdec