transform=train_transformer),
        batch_size=batch_size,
        shuffle=True,
    )

    test_loader = DataLoader(
        datasets.CIFAR10(data_dir, train=False, transform=test_transformer),
        batch_size=batch_size,
        shuffle=True,
    )

    logger = set_logger("classification_cifar10_cnn")

    # FusionClassifier
    model = FusionClassifier(estimator=LeNet5,
                             n_estimators=n_estimators,
                             cuda=True)

    # Set the optimizer
    model.set_optimizer("Adam", lr=lr, weight_decay=weight_decay)

    # Training
    tic = time.time()
    model.fit(train_loader, epochs=epochs)
    toc = time.time()
    training_time = toc - tic

    # Evaluating
    tic = time.time()
    testing_acc = model.evaluate(test_loader)
    toc = time.time()
Пример #2
0
                                                           (0.2023, 0.1994, 0.2010))])
    
    train_loader = DataLoader(datasets.CIFAR10(
        data_dir, train=True, download=True, transform=transformer), 
        batch_size=batch_size, shuffle=True)

    test_loader = DataLoader(datasets.CIFAR10(
        data_dir, train=False, transform=transforms.Compose([
            transforms.ToTensor(), transforms.Normalize((0.4914, 0.4822, 0.4465),
                                                        (0.2023, 0.1994, 0.2010))])),
        batch_size=batch_size, shuffle=True)
    
    # FusionClassifier
    model = FusionClassifier(estimator=LeNet5,
                              n_estimators=n_estimators,
                              output_dim=output_dim,
                              lr=lr,
                              weight_decay=weight_decay,
                              epochs=epochs)
    
    tic = time.time()
    model.fit(train_loader)
    toc = time.time()
    training_time = toc - tic
    
    tic = time.time()
    testing_acc = model.predict(test_loader)
    toc = time.time()
    evaluating_time = toc - tic

    records.append(('FusionClassifier', 
                    training_time,