def __init__(self, src_filedir, tar_filedir, hidden_size=100): self.src_i2w, self.src_w2i, self.X_train = self.process_dataset(src_filedir) self.tar_i2w, self.tar_w2i, self.Y_train = self.process_dataset(tar_filedir, True) self.src_vocab_size = len(self.src_w2i) self.tar_vocab_size = len(self.tar_w2i) self.hidden_size = hidden_size # encoder self.l1 = rm.Embedding(hidden_size, self.src_vocab_size) self.l2 = rm.Lstm(hidden_size) # decoder self.l3 = rm.Embedding(hidden_size, self.tar_vocab_size) self.l4 = rm.Lstm(hidden_size) self.l5 = rm.Dense(self.tar_vocab_size)
def __init__(self): self.d1=rm.Dense(32) self.d2=rm.Dense(32) self.d3=rm.Dense(32) self.d4=rm.Dense(1) self.emb = rm.Embedding(32,6) self.ad1 = rm.Dense(32) self.r=rm.Relu()
def test_embedding(node, use_gpu): node = Variable(node) assert_cuda_active(use_gpu) layer = rm.Embedding(output_size=2, input_size=2) def func(node): return sum(layer(node)) compare(func, layer.params["w"], node)