예제 #1
0
def test_layer_global_max_pooling2d(system_dict):
    forward = True

    test = "test_layer_global_max_pooling2d"
    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_max_pooling2d())
            gtf.Compile_Network(network, data_shape=(3, 32, 32), use_gpu=False)

            x = tf.placeholder(tf.float32, shape=(1, 32, 32, 3))
            y = gtf.system_dict["local"]["model"](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_optimizer_nesterov_sgd(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_nesterov_sgd";
    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="resnet50", freeze_base_network=True, num_epochs=2);
            gtf.optimizer_nesterov_sgd(0.01, momentum=0.9, weight_decay=0.0001, momentum_dampening_rate=0, 
            	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
def test_block_mobilenet_v2_inverted_linear_bottleneck(system_dict):
    forward = True;

    test = "test_block_mobilenet_v2_inverted_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_inverted_linear_bottleneck_block(output_channels=64, bottleneck_width=4, stride=1));
            gtf.Compile_Network(network, data_shape=(64, 64, 64), use_gpu=False);

            x = tf.placeholder(tf.float32, shape=(1, 64, 64, 64))
            y = gtf.system_dict["local"]["model"](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_activation_sigmoid(system_dict):
    forward = True;

    test = "test_activation_sigmoid";
    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.sigmoid());
            gtf.Compile_Network(network, data_shape=(3, 32, 32), use_gpu=False);

            x = tf.placeholder(tf.float32, shape=(1, 32, 32, 3))
            y = gtf.system_dict["local"]["model"](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_squared_hinge(system_dict):
    forward = True

    test = "test_loss_squared_hinge"
    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")

            y = np.random.randn(1, 5)
            label = np.random.randn(1, 5)

            y = K.constant(y)
            label = K.constant(label)

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

            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_block_conv_bn_relu(system_dict):
    forward = True

    test = "test_block_conv_bn_relu"
    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.conv_bn_relu_block(output_channels=64))
            gtf.Compile_Network(network, data_shape=(1, 64, 64), use_gpu=False)

            x = tf.placeholder(tf.float32, shape=(1, 64, 64, 1))
            y = gtf.system_dict["local"]["model"](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
예제 #7
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, data_shape=(1, 64, 64), use_gpu=False)

            x = tf.placeholder(tf.float32, shape=(1, 64, 64, 1))
            y = gtf.system_dict["local"]["model"](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
예제 #8
0
def test_layer_fully_connected(system_dict):
    forward = True

    test = "test_layer_fully_connected"
    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.convolution2d(output_channels=3, kernel_size=3))
            network.append(gtf.flatten())
            network.append(gtf.fully_connected(units=10))
            gtf.Compile_Network(network, data_shape=(3, 32, 32), use_gpu=False)

            x = tf.placeholder(tf.float32, shape=(1, 32, 32, 3))
            y = gtf.system_dict["local"]["model"](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_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");

            y = np.random.randn(1, 5);
            label = np.random.randn(1, 5);

            y = K.constant(y);
            label = K.constant(label);

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

            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, data_shape=(1, 64, 64), use_gpu=False);

            x = tf.placeholder(tf.float32, shape=(1, 64, 64, 1))
            y = gtf.system_dict["local"]["model"](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
예제 #11
0
def test_layer_add(system_dict):
    forward = True

    test = "test_layer_add"
    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))
            network.append(gtf.batch_normalization())
            network.append(gtf.relu())
            network.append(gtf.convolution(output_channels=16))
            network.append(gtf.batch_normalization())
            network.append(gtf.relu())
            network.append(gtf.max_pooling())

            subnetwork = []
            branch1 = []
            branch1.append(gtf.convolution(output_channels=16))
            branch1.append(gtf.batch_normalization())
            branch1.append(gtf.convolution(output_channels=16))
            branch1.append(gtf.batch_normalization())

            branch2 = []
            branch2.append(gtf.convolution(output_channels=16))
            branch2.append(gtf.batch_normalization())

            branch3 = []
            branch3.append(gtf.identity())

            subnetwork.append(branch1)
            subnetwork.append(branch2)
            subnetwork.append(branch3)
            subnetwork.append(gtf.add())

            network.append(subnetwork)
            gtf.Compile_Network(network, data_shape=(3, 32, 32), use_gpu=False)

            x = tf.placeholder(tf.float32, shape=(1, 32, 32, 3))
            y = gtf.system_dict["local"]["model"](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_he_uniform(system_dict):
    forward = True;

    test = "test_initializer_he_uniform";
    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));
            network.append(gtf.batch_normalization());
            network.append(gtf.relu());
            network.append(gtf.convolution(output_channels=32));
            network.append(gtf.batch_normalization());
            network.append(gtf.relu());
            network.append(gtf.average_pooling(kernel_size=2));


            network.append(gtf.convolution(output_channels=64));
            network.append(gtf.batch_normalization());
            network.append(gtf.relu());
            network.append(gtf.convolution(output_channels=64));
            network.append(gtf.batch_normalization());
            network.append(gtf.relu());
            network.append(gtf.average_pooling(kernel_size=2));


            network.append(gtf.convolution(output_channels=128));
            network.append(gtf.batch_normalization());
            network.append(gtf.relu());
            network.append(gtf.convolution(output_channels=128));
            network.append(gtf.batch_normalization());
            network.append(gtf.relu());
            network.append(gtf.average_pooling(kernel_size=2));

            network.append(gtf.flatten());
            network.append(gtf.dropout(drop_probability=0.2));
            network.append(gtf.fully_connected(units=1024));
            network.append(gtf.dropout(drop_probability=0.2));
            network.append(gtf.fully_connected(units=2));
            network.append(gtf.softmax());

            gtf.Compile_Network(network, data_shape=(3, 32, 32), network_initializer="he_uniform");


            x = tf.placeholder(tf.float32, shape=(1, 32, 32, 3))
            y = gtf.system_dict["local"]["model"](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