def __init__(self, nchars=8, length=2, **f_args): self.size = nchars**length self.nchars = nchars self.length = length self.nvocab = self.fixed_vocab self.chars = self.allocate(self.nchars) self.min_char = self.chars[0] self.max_char = self.chars[-1] self.vars = list(sequences(self.chars, length)) self.make_values(**f_args)
def __init__(self, nchars=8, length=2, log_iters=6): self.nvocab = self.fixed_vocab self.nchars = nchars self.length = length self.log_iters = log_iters self.size = nchars**length self.chars = self.allocate(nchars) self.min_char = self.chars[0] self.max_char = self.chars[-1] self.vars = list(sequences(self.chars, length)) self.question_length = length + log_iters self.fact_length = 2 * length self.answer_length = length
def __init__(self, nchars=8, length=2, num_vals=None, easy=False): self.nchars = nchars self.length = length self.num_vars = nchars**length self.num_vals = num_vals or int(np.sqrt(self.num_vars)) self.nvocab = self.fixed_vocab self.chars = self.allocate(self.nchars) self.min_char = self.chars[0] self.max_char = self.chars[-1] self.vars = list(sequences(self.chars, self.length)) self.vals = self.allocate(self.num_vals) self.max_d = self.num_vars - self.num_vals self.depths = self.allocate(self.max_d + 1) self.zero = self.depths[0] self.largest_d = self.depths[-1] self.easy = easy self.fact_length = 2 * length self.answer_length = length self.question_length = 2 * length
def __init__(self, nchars=8, length=2): self.size = nchars**length self.length = length self.nchars = nchars self.nvocab = self.fixed_vocab self.max_d = 2 * log(self.size) self.distances = self.allocate(self.max_d + 2) self.zero = self.distances[0] self.inf = self.distances[-1] self.chars = self.allocate(self.nchars) self.char_powers = nchars**np.flip(np.arange(self.length), axis=0) self.min_char = self.chars[0] self.max_char = self.chars[-1] self.unindex = np.array([(idk, ) * length] + list(sequences(self.chars, length))) self.vertices = self.unindex[1:] self.question_length = 1 + 2 * length self.fact_length = 2 * length self.answer_length = length
def __init__(self, length=6, size=float('inf'), nchars=2, modulus=None): self.nvocab = self.fixed_vocab self.size = min(size, nchars**length) self.alphabet = self.allocate(nchars) self.interaction_length = nchars self.alphabet_plus = np.concatenate([[self.wild], self.alphabet]) self.modulus = modulus if modulus is None: self.max_d = (self.size + nchars - 1) // nchars self.differences = self.allocate(2 * self.max_d + 1) self.zero = self.differences[self.max_d] else: self.differences = self.allocate(self.modulus) self.zero = self.differences[0] self.all_strings = [ np.array(x) for x in sequences(self.alphabet, length) ] self.length = length self.question_length = length self.fact_length = length + 1
def all_questions(self, fast_db): for x in fast_db["vars"]: for n in sequences([self.zero, self.one], self.log_iters): yield np.asarray([x] + n)
def all_questions(self, fast_db): yield from sequences(self.alphabet_plus, self.length)