Example #1
0
    def __init__(self):
        args = commandlineArguments(enumerationTimeout=200,
                                    activation='tanh',
                                    iterations=1,
                                    recognitionTimeout=3600,
                                    a=3,
                                    maximumFrontier=5,
                                    topK=2,
                                    pseudoCounts=30.0,
                                    helmholtzRatio=0.5,
                                    structurePenalty=1.,
                                    CPUs=min(numberOfCPUs(), 8),
                                    extras=list_options)

        args['noConsolidation'] = True
        args.pop("random_seed")
        args['contextual'] = True
        args['biasOptimal'] = True
        args['auxiliaryLoss'] = True
        args['activation'] = "relu"
        args['useDSL'] = False

        extractor = {
            "learned": LearnedFeatureExtractor,
        }[args.pop("extractor")]
        extractor.H = args.pop("hidden")

        timestamp = datetime.datetime.now().isoformat()
        outputDirectory = "tmp/%s" % timestamp
        os.system("mkdir -p %s" % outputDirectory)

        args.update({
            "featureExtractor": extractor,
            "outputPrefix": "%s/hint" % outputDirectory,
            "evaluationTimeout": 0.0005,
        })
        args.pop("maxTasks")
        args.pop("split")

        self.primitives = McCarthyPrimitives()
        baseGrammar = Grammar.uniform(self.primitives)
        self.grammar = baseGrammar
        self.train_args = args
        self.semantics = [Semantics(i) for i in range(len(SYMBOLS))]
        self.allFrontiers = None
        self.helmholtzFrontiers = None
Example #2
0
try:
    import binutil  # required to import from dreamcoder modules
except ModuleNotFoundError:
    import bin.binutil  # alt import if called as module

from dreamcoder.domains.succ.main import main, list_options
from dreamcoder.dreamcoder import commandlineArguments
from dreamcoder.utilities import numberOfCPUs


if __name__ == '__main__':
    args = commandlineArguments(
        enumerationTimeout=10, activation='tanh', iterations=1000, recognitionTimeout=3600,
        a=3, maximumFrontier=10, topK=2, pseudoCounts=30.0,
        helmholtzRatio=0.5, structurePenalty=1.,
        CPUs=numberOfCPUs(),
        extras=list_options)
    main(args)
Example #3
0
File: regexes.py Project: zlapp/ec
try:
    import binutil  # required to import from dreamcoder modules
except ModuleNotFoundError:
    import bin.binutil  # alt import if called as module

from dreamcoder.domains.regex.main import main, regex_options
from dreamcoder.dreamcoder import commandlineArguments
from dreamcoder.utilities import numberOfCPUs


if __name__ == '__main__':
    args = commandlineArguments(
        activation='relu', iterations=10,
        a=3, maximumFrontier=5, topK=2, pseudoCounts=30.0,  # try 1 0.1 would make prior uniform
        helmholtzRatio=0.5, structurePenalty=1.0,  # try
        CPUs=numberOfCPUs(),
        extras=regex_options)
    main(args)
Example #4
0
File: logo.py Project: zlapp/ec
try:
    import binutil  # required to import from dreamcoder modules
except ModuleNotFoundError:
    import bin.binutil  # alt import if called as module

from dreamcoder.domains.logo.main import main, list_options, LogoFeatureCNN
from dreamcoder.dreamcoder import commandlineArguments
from dreamcoder.utilities import numberOfCPUs

if __name__ == '__main__':
    args = commandlineArguments(structurePenalty=1.5,
                                recognitionTimeout=3600,
                                a=3,
                                topK=2,
                                iterations=10,
                                useRecognitionModel=True,
                                helmholtzRatio=0.5,
                                featureExtractor=LogoFeatureCNN,
                                maximumFrontier=5,
                                CPUs=numberOfCPUs(),
                                pseudoCounts=30.0,
                                activation="tanh",
                                extras=list_options)
    main(args)
Example #5
0
def rational_options(p):
    p.add_argument("--smooth",
                   action="store_true",
                   default=False,
                   help="smooth likelihood model")


if __name__ == "__main__":
    import time

    arguments = commandlineArguments(featureExtractor=FeatureExtractor,
                                     iterations=6,
                                     CPUs=numberOfCPUs(),
                                     structurePenalty=1.,
                                     recognitionTimeout=7200,
                                     helmholtzRatio=0.5,
                                     activation="tanh",
                                     maximumFrontier=5,
                                     a=3,
                                     topK=2,
                                     pseudoCounts=30.0,
                                     extras=rational_options)

    primitives = [
        real,
        # f1,
        real_division,
        real_addition,
        real_multiplication
    ]
    baseGrammar = Grammar.uniform(primitives)
    random.seed(42)
Example #6
0
        fpi,
        real_power,
        real_subtraction,
        real_addition,
        real_division,
        real_multiplication
    ] + [
        Program.parse(n)
        for n in ["map", "fold", "empty", "cons", "car", "cdr", "zip"]
    ]
    baseGrammar = Grammar.uniform(equationPrimitives)

    eprint("Got %d equation discovery tasks..." % len(tasks))

    explorationCompression(baseGrammar,
                           tasks,
                           outputPrefix="experimentOutputs/scientificLaws",
                           evaluationTimeout=0.1,
                           testingTasks=[],
                           **commandlineArguments(
                               compressor="ocaml",
                               featureExtractor=DummyFeatureExtractor,
                               iterations=10,
                               CPUs=numberOfCPUs(),
                               structurePenalty=0.5,
                               helmholtzRatio=0.5,
                               a=3,
                               maximumFrontier=10000,
                               topK=2,
                               pseudoCounts=10.0))
Example #7
0
try:
    import binutil  # required to import from dreamcoder modules
except ModuleNotFoundError:
    import bin.binutil  # alt import if called as module

from dreamcoder.domains.tower.main import main, TowerCNN, tower_options
from dreamcoder.dreamcoder import commandlineArguments
from dreamcoder.utilities import numberOfCPUs

if __name__ == '__main__':
    arguments = commandlineArguments(featureExtractor=TowerCNN,
                                     CPUs=numberOfCPUs(),
                                     helmholtzRatio=0.5,
                                     recognitionTimeout=3600,
                                     iterations=6,
                                     a=3,
                                     structurePenalty=1,
                                     pseudoCounts=10,
                                     topK=2,
                                     maximumFrontier=5,
                                     extras=tower_options)
    main(arguments)
Example #8
0
File: text.py Project: zlapp/ec
try:
    import binutil  # required to import from dreamcoder modules
except ModuleNotFoundError:
    import bin.binutil  # alt import if called as module

from dreamcoder.domains.text.main import main, LearnedFeatureExtractor, text_options
from dreamcoder.dreamcoder import commandlineArguments
from dreamcoder.utilities import numberOfCPUs


if __name__ == '__main__':
    arguments = commandlineArguments(
        recognitionTimeout=7200,
        iterations=10,
        helmholtzRatio=0.5,
        topK=2,
        maximumFrontier=5,
        structurePenalty=10.,
        a=3,
        activation="tanh",
        CPUs=numberOfCPUs(),
        featureExtractor=LearnedFeatureExtractor,
        pseudoCounts=30.0,
        extras=text_options)
    main(arguments)