Beispiel #1
0
 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
Beispiel #2
0
 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
Beispiel #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)
Beispiel #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)
Beispiel #5
0
def random_vector():
    return onehot(VECTOR_SIZE, random.randint(0, VECTOR_SIZE - 1))
Beispiel #6
0
def random_vector():
    return onehot(VECTOR_SIZE, random.randint(0, VECTOR_SIZE - 1))