Exemple #1
0
def test():
    # this test only tests the model interface.  If you are testing node types then use nodes_test.py
    testing = Testing()
    test_callbacks(testing)
    test_multiple(testing)
    test_bitcode(testing)
    return testing.GetFailedTests()
Exemple #2
0
def test():
    testing = Testing()
    test_buffer(testing, ell.nodes.PortType.smallReal)
    test_buffer(testing, ell.nodes.PortType.real)
    test_buffer(testing, ell.nodes.PortType.integer)
    test_buffer(testing, ell.nodes.PortType.bigInt)
    test_reorder(testing)
    test_typecast(testing)
    test_unary(testing)
    # test_multiply(testing)  # bugbug: crashing on Linux...
    test_scaling_node(testing)
    test_voice_activity_node(testing)
    test_gru_node_with_vad_reset(testing)
    test_hamming_node(testing)
    test_hanning_node(testing)
    test_mel_filterbank(testing)
    test_fftnode(testing)
    test_fastgrnn_node(testing)
    return testing.GetFailedTests()
Exemple #3
0
def test():
    testing = Testing()
    dataset = ell.data.AutoSupervisedDataset()
    dataset.Load(
        os.path.join(find_ell.get_ell_root(), "examples/data/testData.txt"))
    num = dataset.NumExamples()
    print("Number of Examples:", num)
    testing.ProcessTest("Dataset NumExamples test",
                        testing.IsEqual(int(num), 200))

    features = dataset.NumFeatures()
    print("Number of Features:", features)
    testing.ProcessTest("Dataset NumFeatures test",
                        testing.IsEqual(int(features), 21))

    for i in range(num):
        exampleTest(dataset.GetExample(i))

    testing.ProcessTest("Dataset eumeration test", True)

    return testing.GetFailedTests()
Exemple #4
0
def test():
    testing = Testing()
    test_double(testing)
    test_float(testing)
    return testing.GetFailedTests()
Exemple #5
0
def test():
    testing = Testing()
    # -dd auto -sw 1 -sb 1 -sz 1 -pd 10 -l 2 -mp 5 -v --evaluationFrequency 1 -plf L2

    args = ell.trainers.ProtoNNTrainerParameters()
    args.projectedDimension = 10
    args.numPrototypesPerLabel = 5
    args.numLabels = 2
    args.sparsityW = 1
    args.sparsityB = 1
    args.sparsityZ = 1
    args.gamma = -1
    args.lossFunction = ell.trainers.ProtoNNLossFunction.L2
    args.numInnerIterations = 1
    args.numFeatures = 0
    args.verbose = True

    trainer = ell.trainers.ProtoNNTrainer(args)

    dataset = ell.data.AutoSupervisedDataset()
    testFile = os.path.join(find_ell.get_ell_root(),
                            "examples/data/protonnTestData.txt")
    print("Loading: " + testFile)
    dataset.Load(testFile)

    total = dataset.NumExamples()
    features = dataset.NumFeatures()
    testing.ProcessTest("ProtoNN dataset loaded",
                        testing.IsEqual(int(total), 200))

    trainer.SetDataset(dataset)

    numIterations = 20

    print("Training...")
    for i in range(numIterations):
        trainer.Update()

    predictor = trainer.GetPredictor()

    accuracy = get_accuracy(predictor, dataset, features, predictor.Predict)
    print("Accuracy %f" % (accuracy))
    testing.ProcessTest("ProtoNN accuracy test",
                        testing.IsEqual(int(accuracy), 1))

    map = predictor.GetMap()
    map.Save("protonnTestData.ell")
    testing.ProcessTest(
        "Saving  protonnTestData.ell",
        testing.IsEqual(os.path.isfile("protonnTestData.ell"), True))

    # make sure we can compile this map.
    try:
        compilerSettings = ell.model.MapCompilerOptions()
        compilerSettings.useBlas = False
        optimizerSettings = ell.model.ModelOptimizerOptions()
        compiledMap = map.Compile("host", "protonn", "predict",
                                  compilerSettings, optimizerSettings)
        compiled = True
    except Exception as e:
        print("Compile ProtoNN model failed: {}", e)
        compiled = False

    testing.ProcessTest("Compiling protonnTestData.ell",
                        testing.IsEqual(compiled, True))
    if compiled:
        accuracy = get_accuracy(predictor, dataset, features,
                                compiledMap.Compute)
        print("Compiled Accuracy %f" % (accuracy))
        testing.ProcessTest("ProtoNN compiled accuracy test",
                            testing.IsEqual(int(accuracy), 1))

    return testing.GetFailedTests()
Exemple #6
0
def test():
    testing = Testing()
    testModelBuilder(testing)
    return testing.GetFailedTests()
Exemple #7
0
def test():
    testing = Testing()
    test_tensor(testing)
    test_predictor(testing)
    return testing.GetFailedTests()
Exemple #8
0
def test():
    testing = Testing()
    hingeLossTest(testing)
    logLossTest(testing)
    squaredLossTest(testing)
    return testing.GetFailedTests()