def __init__(self, seq_len=0, use_cuda=True, device=None): self.embedder = elmo.Embedder(batch_size=512, use_cuda=use_cuda) self.seq_len = seq_len self.bos_vec, self.eos_vec = np.load("bos_eos.npy") self.pad, self.oov = np.load("pad_oov.npy") self.device = device if self.device != None: self.embedder.model.to(self.device)
def __init__(self, seq_len=0, use_cuda=True, device=None): self.embedder = elmo.Embedder(model_dir="zhuyin.model", batch_size=512, use_cuda=use_cuda) self.seq_len = seq_len self.device = device if self.device != None: self.embedder.model.to(self.device) self.bos_vec, self.eos_vec, self.pad, self.oov = self.embedder.sents2elmo( [["<bos>", "<eos>", "<pad>", "<oov>"]], output_layer=0)[0]
def __init__(self, seq_len=0, use_cuda=True, run_device=None, target_device=None, d_model=1024): super(Embedder, self).__init__() self.embedder = elmo.Embedder(model_dir="new.model", batch_size=512, use_cuda=use_cuda) self.seq_len = seq_len self.device = run_device self.target_device = target_device if self.device != None: self.embedder.model.to(self.device) self.bos_vec, self.eos_vec, self.pad, self.oov = self.embedder.sents2elmo( [["<bos>", "<eos>", "<pad>", "<oov>"]], output_layer=0)[0]
def __init__(self): self.embedder = elmo.Embedder(batch_size=512)