示例#1
0
文件: Data.py 项目: moverlan/LOTlib
def generate_data(data_size):
    """
    Sample some data according to the target
    """
    data = []
    for i in range(data_size):
        # how many in this set
        set_size = weighted_sample( 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))  # convert to "FunctionData" and store
    return data
示例#2
0
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(
            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
示例#3
0
文件: Model.py 项目: piantado/LOTlib
 def sample_output(self, datum):
     # return a sample of my output given the input in datum
     if random() < datum.alpha:
         return self(*datum.input)
     else:
         return weighted_sample(WORDS)  # uniform sample
示例#4
0
 def sample_output(self, datum):
     # return a sample of my output given the input in datum
     if random() < datum.alpha:
         return self(*datum.input)
     else:
         return weighted_sample(WORDS)  # uniform sample