Пример #1
0
def test_activation_tanh(system_dict):
    forward = True

    test = "test_activation_tanh"
    system_dict["total_tests"] += 1
    print_start(test, system_dict["total_tests"])
    if (forward):
        try:
            gtf = prototype(verbose=0)
            gtf.Prototype("sample-project-1", "sample-experiment-1")

            network = []
            network.append(gtf.tanh())
            gtf.Compile_Network(network)

            x = np.random.rand(1, 64, 4)
            x = mx.nd.array(x)
            y = gtf.system_dict["local"]["model"].forward(x)

            system_dict["successful_tests"] += 1
            print_status("Pass")

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e)
            system_dict["failed_tests_lists"].append(test)
            forward = False
            print_status("Fail")
    else:
        system_dict["skipped_tests_lists"].append(test)
        print_status("Skipped")

    return system_dict
Пример #2
0
def test_block_squeezenet_fire(system_dict):
    forward = True

    test = "test_block_squeezenet_fire"
    system_dict["total_tests"] += 1
    print_start(test, system_dict["total_tests"])
    if (forward):
        try:
            gtf = prototype(verbose=0)
            gtf.Prototype("sample-project-1", "sample-experiment-1")

            network = []
            network.append(
                gtf.squeezenet_fire_block(squeeze_channels=16,
                                          expand_channels_1x1=32,
                                          expand_channels_3x3=64))
            gtf.Compile_Network(network, use_gpu=False)

            x = np.random.rand(1, 1, 64, 64)
            x = mx.nd.array(x)
            y = gtf.system_dict["local"]["model"].forward(x)

            system_dict["successful_tests"] += 1
            print_status("Pass")

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e)
            system_dict["failed_tests_lists"].append(test)
            forward = False
            print_status("Fail")
    else:
        system_dict["skipped_tests_lists"].append(test)
        print_status("Skipped")

    return system_dict
Пример #3
0
def test_layer_global_average_pooling3d(system_dict):
    forward = True;

    test = "test_layer_average_pooling3d";
    system_dict["total_tests"] += 1;
    print_start(test, system_dict["total_tests"])
    if(forward):
        try:
            gtf = prototype(verbose=0);
            gtf.Prototype("sample-project-1", "sample-experiment-1");


            network = [];
            network.append(gtf.global_average_pooling3d());
            gtf.Compile_Network(network, use_gpu=False);

            x = np.random.rand(1, 1, 10, 64, 64);
            x = mx.nd.array(x);
            y = gtf.system_dict["local"]["model"].forward(x);          

            system_dict["successful_tests"] += 1;
            print_status("Pass");

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e);
            system_dict["failed_tests_lists"].append(test);
            forward = False;
            print_status("Fail");
    else:
        system_dict["skipped_tests_lists"].append(test);
        print_status("Skipped");

    return system_dict
Пример #4
0
def test_layer_transposed_convolution1d(system_dict):
    forward = True

    test = "test_layer_transposed_convolution1d"
    system_dict["total_tests"] += 1
    print_start(test, system_dict["total_tests"])
    if (forward):
        try:
            gtf = prototype(verbose=0)
            gtf.Prototype("sample-project-1", "sample-experiment-1")

            network = []
            network.append(
                gtf.transposed_convolution1d(output_channels=3, kernel_size=3))
            gtf.Compile_Network(network, use_gpu=False)

            x = np.random.rand(1, 64, 3)
            x = mx.nd.array(x)
            y = gtf.system_dict["local"]["model"].forward(x)

            system_dict["successful_tests"] += 1
            print_status("Pass")

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e)
            system_dict["failed_tests_lists"].append(test)
            forward = False
            print_status("Fail")
    else:
        system_dict["skipped_tests_lists"].append(test)
        print_status("Skipped")

    return system_dict
Пример #5
0
def test_loss_poisson_nll(system_dict):
    forward = True

    test = "test_loss_poisson_nll"
    system_dict["total_tests"] += 1
    print_start(test, system_dict["total_tests"])
    if (forward):
        try:
            gtf = prototype(verbose=0)
            gtf.Prototype("sample-project-1", "sample-experiment-1")

            label = np.random.rand(1, 5)
            label = mx.nd.array(label)

            y = np.random.rand(1, 5)
            y = mx.nd.array(y)

            gtf.loss_poisson_nll()
            load_loss(gtf.system_dict)
            loss_obj = gtf.system_dict["local"]["criterion"]
            loss_val = loss_obj(y, label)

            system_dict["successful_tests"] += 1
            print_status("Pass")

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e)
            system_dict["failed_tests_lists"].append(test)
            forward = False
            print_status("Fail")
    else:
        system_dict["skipped_tests_lists"].append(test)
        print_status("Skipped")

    return system_dict
Пример #6
0
def test_loss_kldiv(system_dict):
    forward = True;

    test = "test_loss_kldiv";
    system_dict["total_tests"] += 1;
    print_start(test, system_dict["total_tests"])
    if(forward):
        try:
            gtf = prototype(verbose=0);
            gtf.Prototype("sample-project-1", "sample-experiment-1");

            label = [1, 0, 1, 0, 1];
            label = mx.nd.array(label);

            y = np.random.rand(1, 5);
            y = mx.nd.array(y);

            gtf.loss_kldiv();
            load_loss(gtf.system_dict);
            loss_obj = gtf.system_dict["local"]["criterion"];
            loss_val = loss_obj(y, label);           

            system_dict["successful_tests"] += 1;
            print_status("Pass");

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e);
            system_dict["failed_tests_lists"].append(test);
            forward = False;
            print_status("Fail");
    else:
        system_dict["skipped_tests_lists"].append(test);
        print_status("Skipped");

    return system_dict
Пример #7
0
def test_optimizer_rmsprop(system_dict):
    forward = True;
    if(not os.path.isdir("datasets")):
        os.system("! wget --load-cookies /tmp/cookies.txt \"https://docs.google.com/uc?export=download&confirm=$(wget --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1rG-U1mS8hDU7_wM56a1kc-li_zHLtbq2' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1rG-U1mS8hDU7_wM56a1kc-li_zHLtbq2\" -O datasets.zip && rm -rf /tmp/cookies.txt")
        os.system("! unzip -qq datasets.zip")

    test = "test_optimizer_rmsprop";
    system_dict["total_tests"] += 1;
    print_start(test, system_dict["total_tests"])
    if(forward):
        try:
            gtf = prototype(verbose=0);
            gtf.Prototype("sample-project-1", "sample-experiment-1");
            gtf.Default(dataset_path="datasets/dataset_cats_dogs_train", 
                model_name="resnet18_v1", freeze_base_network=True, num_epochs=2);
            gtf.optimizer_rmsprop(0.01, weight_decay=0.0001, decay_rate=0.9, 
            	clipnorm=1.0, clipvalue=0.5);
            gtf.Train();
            system_dict["successful_tests"] += 1;
            print_status("Pass");
        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e);
            system_dict["failed_tests_lists"].append(test);
            forward = False;
            print_status("Fail");
    else:
        system_dict["skipped_tests_lists"].append(test);
        print_status("Skipped");

    return system_dict
Пример #8
0
def test_block_densenet(system_dict):
    forward = True

    test = "test_block_densenet"
    system_dict["total_tests"] += 1
    print_start(test, system_dict["total_tests"])
    if (forward):
        try:
            gtf = prototype(verbose=0)
            gtf.Prototype("sample-project-1", "sample-experiment-1")

            network = []
            network.append(
                gtf.densenet_block(bottleneck_size=4,
                                   growth_rate=16,
                                   dropout=0.2))
            gtf.Compile_Network(network, use_gpu=False)

            x = np.random.rand(1, 1, 64, 64)
            x = mx.nd.array(x)
            y = gtf.system_dict["local"]["model"].forward(x)

            system_dict["successful_tests"] += 1
            print_status("Pass")

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e)
            system_dict["failed_tests_lists"].append(test)
            forward = False
            print_status("Fail")
    else:
        system_dict["skipped_tests_lists"].append(test)
        print_status("Skipped")

    return system_dict
Пример #9
0
def test_block_mobilenet_v2_linear_bottleneck(system_dict):
    forward = True

    test = "test_block_mobilenet_v2_linear_bottleneck"
    system_dict["total_tests"] += 1
    print_start(test, system_dict["total_tests"])
    if (forward):
        try:
            gtf = prototype(verbose=0)
            gtf.Prototype("sample-project-1", "sample-experiment-1")

            network = []
            network.append(
                gtf.mobilenet_v2_linear_bottleneck_block(output_channels=64,
                                                         bottleneck_width=4,
                                                         stride=1))
            gtf.Compile_Network(network, use_gpu=False)

            x = np.random.rand(1, 64, 64, 64)
            x = mx.nd.array(x)
            y = gtf.system_dict["local"]["model"].forward(x)

            system_dict["successful_tests"] += 1
            print_status("Pass")

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e)
            system_dict["failed_tests_lists"].append(test)
            forward = False
            print_status("Fail")
    else:
        system_dict["skipped_tests_lists"].append(test)
        print_status("Skipped")

    return system_dict
Пример #10
0
def test_block_inception_a(system_dict):
    forward = True;

    test = "test_block_inception_a";
    system_dict["total_tests"] += 1;
    print_start(test, system_dict["total_tests"])
    if(forward):
        try:
            gtf = prototype(verbose=0);
            gtf.Prototype("sample-project-1", "sample-experiment-1");


            network = [];
            network.append(gtf.inception_a_block(pooling_branch_channels=32, pool_type="avg"));
            network.append(gtf.inception_a_block(pooling_branch_channels=32, pool_type="max"));
            gtf.Compile_Network(network, use_gpu=False);

            x = np.random.rand(1, 1, 64, 64);
            x = mx.nd.array(x);
            y = gtf.system_dict["local"]["model"].forward(x);          

            system_dict["successful_tests"] += 1;
            print_status("Pass");

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e);
            system_dict["failed_tests_lists"].append(test);
            forward = False;
            print_status("Fail");
    else:
        system_dict["skipped_tests_lists"].append(test);
        print_status("Skipped");

    return system_dict
def test_initializer_xavier_normal(system_dict):
    forward = True

    test = "test_initializer_xavier_normal"
    system_dict["total_tests"] += 1
    print_start(test, system_dict["total_tests"])
    if (forward):
        try:
            gtf = prototype(verbose=0)
            gtf.Prototype("sample-project-1", "sample-experiment-1")

            network = []
            network.append(gtf.convolution(output_channels=16, uid="conv1"))
            network.append(gtf.batch_normalization(uid="bn1"))
            network.append(gtf.relu(uid="relu1"))
            network.append(gtf.convolution(output_channels=16, uid="conv2"))
            network.append(gtf.batch_normalization(uid="bn2"))
            network.append(gtf.relu(uid="relu2"))
            network.append(gtf.max_pooling(uid="pool1"))

            network.append(gtf.flatten(uid="flatten1"))
            network.append(gtf.fully_connected(units=1024, uid="fc1"))
            network.append(gtf.dropout(drop_probability=0.2, uid="dp1"))
            network.append(gtf.fully_connected(units=2, uid="fc2"))

            gtf.Compile_Network(network,
                                use_gpu=False,
                                network_initializer="xavier_normal")

            x = np.random.rand(1, 1, 64, 64)
            x = mx.nd.array(x)
            y = gtf.system_dict["local"]["model"].forward(x)

            system_dict["successful_tests"] += 1
            print_status("Pass")

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e)
            system_dict["failed_tests_lists"].append(test)
            forward = False
            print_status("Fail")
    else:
        system_dict["skipped_tests_lists"].append(test)
        print_status("Skipped")

    return system_dict
Пример #12
0
def test_layer_concatenate(system_dict):
    forward = True

    test = "test_layer_concatenate"
    system_dict["total_tests"] += 1
    print_start(test, system_dict["total_tests"])
    if (forward):
        try:
            gtf = prototype(verbose=0)
            gtf.Prototype("sample-project-1", "sample-experiment-1")

            network = []
            network.append(gtf.convolution(output_channels=16, uid="conv1"))
            network.append(gtf.batch_normalization(uid="bn1"))
            network.append(gtf.relu(uid="relu1"))
            network.append(gtf.max_pooling(uid="pool1"))

            subnetwork = []
            branch1 = []
            branch1.append(gtf.convolution(output_channels=16,
                                           uid="conv3_1_1"))
            branch1.append(gtf.batch_normalization(uid="bn3_1_1"))
            branch1.append(gtf.convolution(output_channels=16,
                                           uid="conv3_1_2"))
            branch1.append(gtf.batch_normalization(uid="bn3_1_2"))

            branch2 = []
            branch2.append(gtf.convolution(output_channels=16,
                                           uid="conv3_2_1"))
            branch2.append(gtf.batch_normalization(uid="bn3_2_1"))

            branch3 = []
            branch3.append(gtf.identity(uid="identity1"))

            subnetwork.append(branch1)
            subnetwork.append(branch2)
            subnetwork.append(branch3)
            subnetwork.append(gtf.concatenate(uid="concat1"))

            network.append(subnetwork)

            network.append(gtf.convolution(output_channels=16, uid="conv4"))
            network.append(gtf.batch_normalization(uid="bn4"))
            network.append(gtf.relu(uid="relu3"))
            network.append(gtf.max_pooling(uid="pool4"))

            network.append(gtf.flatten(uid="flatten1"))
            network.append(gtf.fully_connected(units=1024, uid="fc1"))
            network.append(gtf.dropout(drop_probability=0.2, uid="dp1"))
            network.append(gtf.fully_connected(units=2, uid="fc2"))

            gtf.Compile_Network(network, use_gpu=False)

            x = np.random.rand(1, 1, 64, 64)
            x = mx.nd.array(x)
            y = gtf.system_dict["local"]["model"].forward(x)

            system_dict["successful_tests"] += 1
            print_status("Pass")

        except Exception as e:
            system_dict["failed_tests_exceptions"].append(e)
            system_dict["failed_tests_lists"].append(test)
            forward = False
            print_status("Fail")
    else:
        system_dict["skipped_tests_lists"].append(test)
        print_status("Skipped")

    return system_dict