Exemplo n.º 1
0
Arquivo: lm.py Projeto: OlafLee/deepy
 def sample(self, input, steps):
     """
     Sample outputs from LM.
     """
     inputs = [[onehot(self.input_dim, x) for x in input]]
     for _ in range(steps):
         target = self.compute(inputs)[0, -1].argmax()
         input.append(target)
         inputs[0].append(onehot(self.input_dim, target))
     return input
Exemplo n.º 2
0
Arquivo: lm.py Projeto: yochju/deepy
 def sample(self, input, steps):
     """
     Sample outputs from LM.
     """
     inputs = [[onehot(self.input_dim, x) for x in input]]
     for _ in range(steps):
         target = self.compute(inputs)[0, -1].argmax()
         input.append(target)
         inputs[0].append(onehot(self.input_dim, target))
     return input
Exemplo n.º 3
0
 def prepare(self):
     if not self.cached:
         return
     onehot_matrix = []
     for i in xrange(self.vocab_size):
         onehot_matrix.append(onehot(self.vocab_size, i))
     onehot_matrix = np.array(onehot_matrix, dtype=FLOATX)
     self.onehot_list = self.create_matrix(self.vocab_size, self.vocab_size, "onehot_list")
     self.onehot_list.set_value(onehot_matrix)
Exemplo n.º 4
0
 def prepare(self):
     if not self.cached:
         return
     onehot_matrix = []
     for i in xrange(self.vocab_size):
         onehot_matrix.append(onehot(self.vocab_size, i))
     onehot_matrix = np.array(onehot_matrix, dtype=FLOATX)
     self.onehot_list = self.create_matrix(self.vocab_size, self.vocab_size,
                                           "onehot_list")
     self.onehot_list.set_value(onehot_matrix)
Exemplo n.º 5
0
def random_vector():
    return onehot(VECTOR_SIZE, random.randint(0, VECTOR_SIZE - 1))
Exemplo n.º 6
0
Arquivo: util.py Projeto: 52nlp/deepy
def random_vector():
    return onehot(VECTOR_SIZE, random.randint(0, VECTOR_SIZE - 1))