Exemplo n.º 1
0
import matplotlib.pyplot as plt

import al
from al.dataset import mnist
from al.model.model_zoo.simple_cnn import ConvModel
from al.model.mnist import MnistLearner
from al.dataset.mnist import MnistDataset
from al.train.active_train import ActiveTrain
from al.helpers.experiment import set_up_experiment, load_config
from al.experiments import set_up_learner

DATASET = 'mnist'

FOLDER_PATH = os.path.dirname(__file__)
OUTPUT_DIR, FIGURE_DIR, logger, logger_name = set_up_experiment(__file__,
                                                                FOLDER_PATH,
                                                                logging_lvl=20)

config = load_config(FOLDER_PATH, DATASET)
setupper = set_up_learner(DATASET)
config['active_learning']['output_dir'] = OUTPUT_DIR
config['experiment']['logger_name'] = logger_name
model_name = config['experiment']['model']
dataset, learner = setupper(config, OUTPUT_DIR, logger)

queried = os.path.join(os.path.dirname(__file__), 'results',
                       'queries-margin_sampling-0-simplenet.txt')
df = pd.read_csv(queried, header=0, skiprows=1)
# print(df)
query_step = 0
plot_size = 32
Exemplo n.º 2
0
from al.train.active_train import ActiveTrain
from al.helpers.experiment import set_up_experiment, load_config
from al.experiments import set_up_learner

EXPERIMENT_NAME = 'initial_training_data'
FOLDER_PATH = os.path.expanduser(
    f'~/Documents/active-learning/experiments/{EXPERIMENT_NAME}')
DATASETS = ['mnist', 'cifar', 'pascalvoc_detection']
dataset_to_initsizes = {
    'mnist': [10, 30, 100, 300, 1000],
    'cifar': [100, 300, 1000, 3000, 10000],
    'pascalvoc_detection': [100, 300, 500, 1000]
}
REPEATS = 2

OUTPUT_DIR, FIGURE_DIR, logger, logger_name = set_up_experiment(
    EXPERIMENT_NAME)


def run_single_experiment(dataset_name, init_size):
    logger.info(f'INITIAL SIZE : {init_size}')
    config = load_config(FOLDER_PATH, dataset_name)
    setupper = set_up_learner(dataset_name)
    config['active_learning']['output_dir'] = OUTPUT_DIR
    config['active_learning']['init_size'] = init_size
    config['experiment']['logger_name'] = logger_name
    logger.debug('Getting dataset and learner')
    dataset, learner = setupper(config, OUTPUT_DIR, logger)
    logger.debug('Getting trainer')
    trainer = ActiveTrain(learner, dataset, config['experiment']['strategy'],
                          logger_name)
    logger.debug('Training...')