ellisk42/ec

How to prepare the training data set for primitives with boolean type? (Question)

dongchen-coder opened this issue · 1 comments

Just following incur.py, I am trying to add a primitive '<' which takes two ints and returns a boolean.

def _le(x, y): return lambda x, y: x < y

primitives = [
        ...
        Primitive("loc_le", arrow(tint, tint, tboolean), _le),
]

def leGen():
        x = random.choice(range(500))
        y = random.choice(range(500))
        return {"i": (x, y), "o": x < y}

training_examples = [
        ...
        {"name": "le_train",  "examples": [leGen()  for _ in range(50000)]},
]
training = [get_tint_task(item) for item in training_examples]

It seems that all my tint -> tint -> tint tasks are passed but for tasks with tboolean are failed.

HIT add_train w/ (lambda (lambda (add $0 $1))) ; log prior = -6.761573 ; log likelihood = 0.000000
HIT sub_train w/ (lambda (lambda (sub $1 $0))) ; log prior = -6.761573 ; log likelihood = 0.000000
HIT mul_train w/ (lambda (lambda (mul $0 $1))) ; log prior = -6.761573 ; log likelihood = 0.000000
HIT div_train w/ (lambda (lambda (div $1 $0))) ; log prior = -6.761573 ; log likelihood = 0.000000
MISS le_train
Hits 4/5 tasks

My guess is the training data, which contains python booleans True/False, are not recognized by Ocaml.

What is the right way to specify boolean data for training in python script with ocaml backend.

Thanks!

Using python False and True will be good. I located the bug that I introduced in get_tiny_task.