Ejemplo n.º 1
0
def test_mobilenet1_0():
    sym_path = "./data/mobilenet1_0.json"
    prm_path = "./data/mobilenet1_0.params"
    if not path.exists(sym_path) or not path.exists(prm_path):
        save_mobilenet1_0()
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    validate_model(sym_path, prm_path, ctx, iter_num=999999, dump_model=True)
Ejemplo n.º 2
0
def test_trec():
    sym_path = "./data/trec.json"
    prm_path = "./data/trec.params"
    ctx = [mx.gpu(int(i)) for i in "3".split(',') if i.strip()]
    validate_model(sym_path, prm_path, ctx, ds_name="trec",
                   input_shape=(38, 16), input_prec=16,
                   dump_model=True, dump_shape=(38, 1))
Ejemplo n.º 3
0
def test_tf_resnet50_v1():
    sym_path = "./data/tf_resnet50_v1.json"
    prm_path = "./data/tf_resnet50_v1.params"
    # if not path.exists(sym_path) or not path.exists(prm_path):
    if True:
        tf_dump_model("resnet50_v1")
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    validate_model(sym_path, prm_path, ctx)
Ejemplo n.º 4
0
def test_qd10_resnetv1_20():
    sym_path = "./data/quick_raw_qd_animal10_2_cifar_resnet20_v2.json"
    prm_path = "./data/quick_raw_qd_animal10_2_cifar_resnet20_v2.params"
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    # validate_model(sym_path, prm_path, ctx, num_channel=1,
    #         input_size=28, ds_name='quickdraw', dump_model=True)
    validate_model(sym_path, prm_path, ctx, num_channel=1,
            input_size=28, ds_name='quickdraw', iter_num=999999)
Ejemplo n.º 5
0
def test_cifar10_resnet20_v1():
    sym_path = "./data/cifar_resnet20_v1.json"
    prm_path = "./data/cifar_resnet20_v1.params"
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    # validate_model(sym_path, prm_path, ctx, input_size=32,
    #                ds_name='cifar10', dump_model=True)
    validate_model(sym_path, prm_path, ctx, input_size=32,
                   ds_name='cifar10', iter_num=9999999)
Ejemplo n.º 6
0
def test_tf_inceptionv3():
    sym_path = "./data/tf_inception_v3.json"
    prm_path = "./data/tf_inception_v3.params"
    if not path.exists(sym_path) or not path.exists(prm_path):
        tf_dump_model("inception_v3")
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    # validate_model(sym_path, prm_path, ctx, input_size=299, dump_model=True)
    validate_model(sym_path, prm_path, ctx, input_size=299, iter_num=99999999)
Ejemplo n.º 7
0
def test_quickdraw():
    sym_path = "./data/quickdraw_wlt_augmentation_epoch-4-0.8164531394275162.json"
    prm_path = "./data/quickdraw_wlt_augmentation_epoch-4-0.8164531394275162.params"
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    # validate_model(sym_path, prm_path, ctx, input_size=28, num_channel=1,
    #                ds_name="quickdraw", dump_model=True)
    validate_model(sym_path, prm_path, ctx, input_size=28, num_channel=1,
                   ds_name="quickdraw", iter_num=9999999)
Ejemplo n.º 8
0
def test_alexnet():
    sym_path = "./data/alexnet.json"
    prm_path = "./data/alexnet.params"
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    # validate_model(sym_path, prm_path, batch_size=700, ctx=ctx, dump_model=True)
    validate_model(sym_path,
                   prm_path,
                   batch_size=700,
                   ctx=ctx,
                   iter_num=9999999)
Ejemplo n.º 9
0
def create_model(arch, hidden_units):

    global training_data

    arch = arch.lower()
    is_valid, model, input_dimension = validate_model(arch)

    if is_valid:

        for param in model.parameters():
            param.requires_grad = False

        model.classifier = nn.Sequential(
            OrderedDict([('fc1', nn.Linear(input_dimension, hidden_units)),
                         ('relu', nn.ReLU()), ('drpot', nn.Dropout(p=0.05)),
                         ('fc2',
                          nn.Linear(hidden_units, len(training_data.classes))),
                         ('output', nn.LogSoftmax(dim=1))]))

        print("Hidden units : {}".format(hidden_units))

    return model
Ejemplo n.º 10
0
# scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=10, gamma=0.8)

for ep in range(epoch):

    rec_sys_model, optimizer, avg_train_loss, avg_train_recall = model_utils.train_model(
        rec_sys_model, loss_func, optimizer, train_loader, ep, top_k,
        train_display_step)
    # train_losses.append(avg_train_loss)
    # train_recalls.append(avg_train_recall)
    print("Train loss: ", avg_train_loss)
    print("Train recall: ", avg_train_recall)
    writer.add_scalar("Loss/train", avg_train_loss, ep)
    writer.add_scalar("Recall/train", avg_train_recall, ep)

    avg_val_loss, avg_val_recall = model_utils.validate_model(
        rec_sys_model, loss_func, valid_loader, ep, top_k, val_display_step)
    # val_losses.append(avg_val_loss)
    # val_recalls.append(avg_val_recall)
    print("Val loss: ", avg_val_loss)
    print("Val recall: ", avg_val_recall)
    writer.add_scalar("Loss/val", avg_val_loss, ep)
    writer.add_scalar("Recall/val", avg_val_recall, ep)

    avg_test_loss, avg_test_recall = model_utils.test_model(
        rec_sys_model, loss_func, test_loader, ep, top_k, test_display_step)
    # test_losses.append(avg_test_loss)
    # test_recalls.append(avg_test_recall)

    writer.add_scalar("Loss/test", avg_test_loss, ep)
    writer.add_scalar("Recall/test", avg_test_recall, ep)
Ejemplo n.º 11
0
def test_squeezenet():
    sym_path = "./data/squeezenet1.0.json"
    prm_path = "./data/squeezenet1.0.params"
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    # validate_model(sym_path, prm_path, ctx, batch_size=60, dump_model=True)
    validate_model(sym_path, prm_path, ctx, batch_size=60, iter_num=9999999)
Ejemplo n.º 12
0
def test_shufflenet_v1():
    sym_path = "./data/shufflenet_v1.json"
    prm_path = "./data/shufflenet_v1.params"
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    # validate_model(sym_path, prm_path, ctx, dump_model=True)
    validate_model(sym_path, prm_path, ctx, iter_num=9999999)
Ejemplo n.º 13
0
def test_densenet161():
    sym_path = "./data/densenet161.json"
    prm_path = "./data/densenet161.params"
    ctx = [mx.gpu(int(i)) for i in "1,2,3,4,5".split(',') if i.strip()]
    # validate_model(sym_path, prm_path, ctx, batch_size=16, dump_model=True)
    validate_model(sym_path, prm_path, ctx, batch_size=16, iter_num=9999999)
Ejemplo n.º 14
0
def test_resnet(suffix):
    sym_path = "./data/resnet" + suffix + ".json"
    prm_path = "./data/resnet" + suffix + ".params"
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    # validate_model(sym_path, prm_path, ctx, lambd=16, dump_model=True)
    validate_model(sym_path, prm_path, ctx, lambd=16, iter_num=999999)
Ejemplo n.º 15
0
def test_mobilenet_v2_1_0():
    sym_path = "./data/mobilenetv2_1.0.json"
    prm_path = "./data/mobilenetv2_1.0.params"
    ctx = [mx.gpu(int(i)) for i in "4".split(',') if i.strip()]
    validate_model(sym_path, prm_path, ctx)
Ejemplo n.º 16
0
def test_vgg19():
    sym_path = "./data/vgg19.json"
    prm_path = "./data/vgg19.params"
    ctx = [mx.gpu(int(i)) for i in "3".split(',') if i.strip()]
    # validate_model(sym_path, prm_path, ctx, dump_model=True)
    validate_model(sym_path, prm_path, ctx, iter_num=999999)