def make_data(n=1, alpha=0.999): return [ FunctionData(input=[Obj(shape='square', color='red')], output=True, alpha=alpha), FunctionData(input=[Obj(shape='square', color='blue')], output=False, alpha=alpha), FunctionData(input=[Obj(shape='triangle', color='blue')], output=False, alpha=alpha), FunctionData(input=[Obj(shape='triangle', color='red')], output=False, alpha=alpha) ] * n
def load_words_and_data(path): """ Takes a data path and return [words, data] """ # Load the data data = [] with open(path, 'r') as f: for l in f: if re.match(r"\s*#", l): continue # skip comments if not re.match(r"[^\s]", l): continue # skip whitespace lhs, output = re.split(r"\s*=\s*", l.strip()) args = re.split(r"\s+", lhs) data.append(FunctionData(input=args, output=output)) #print "Loading data", args, "->", output # Figure out all the words! (here, tokens) words = set() for di in data: words.add(di.output) [words.add(x) for x in di.input] words = list(words) return [words, data]
def make_data(n=1): return [ FunctionData( input=[{Obj(color='red'), Obj(color='red'), Obj(color='green')}], output=True, alpha=0.99) ] * n
def make_data(size=1, alpha=0.99): return [FunctionData(input=['aaaa'], output=True, alpha=alpha), FunctionData(input=['aaab'], output=False, alpha=alpha), FunctionData(input=['aabb'], output=False, alpha=alpha), FunctionData(input=['aaba'], output=False, alpha=alpha), FunctionData(input=['aca'], output=True, alpha=alpha), FunctionData(input=['aaca'], output=True, alpha=alpha), FunctionData(input=['a'], output=True, alpha=alpha)] * size
def make_data(n=1): return [ FunctionData(input=[1000.], output=1500., ll_sd=data_sd), FunctionData(input=[828.], output=1340., ll_sd=data_sd), FunctionData(input=[800.], output=1328., ll_sd=data_sd), FunctionData(input=[600.], output=1172., ll_sd=data_sd), FunctionData(input=[300.], output=800., ll_sd=data_sd), FunctionData(input=[0.], output=0., ll_sd=data_sd) # added 0,0 since it makes physical sense. ] * n
def make_data(data_size=300, alpha=0.75): """ Sample some data according to the target """ data = [] for i in range(data_size): # how many in this set set_size = weighted_sample( list(range(1, 10 + 1)), probs=[7187, 1484, 593, 334, 297, 165, 151, 86, 105, 112]) # get the objects in the current set s = set(sample_sets_of_objects(set_size, all_objects)) # sample according to the target if random() < alpha: r = WORDS[len(s) - 1] else: r = weighted_sample(WORDS) # and append the sampled utterance data.append(FunctionData(input=[s], output=r, alpha=alpha)) return data
def make_data(n=1, alpha=0.99): data = [] for x in range(1, 10): data.append( FunctionData(input=['even', x], output=(x % 2 == 0), alpha=alpha) ) data.append( FunctionData(input=['odd', x], output=(x % 2 == 1), alpha=alpha) ) return data*n