help='Path to single model checkpoint (.pkl) file.')
    args = parser.parse_args()

    checkpoint_file = args.checkpoint_file
    fold = int(args.split)
    dataset_path = os.path.join(data_paths.tfd_data_path, 'npy_files/TFD_96/split_'+str(fold))

    print 'Checkpoint: %s' % checkpoint_file
    print 'Testing on split %d\n' % fold

    # Load model
    model = SupervisedModel('evaluation', './')

    # Load dataset
    supervised_data_loader = SupervisedDataLoader(dataset_path)
    test_data_container = supervised_data_loader.load(2)
    test_data_container.X = numpy.float32(test_data_container.X)
    test_data_container.X /= 255.0
    test_data_container.X *= 2.0

    # Construct evaluator
    preprocessor = [util.Normer3(filter_size=5, num_channels=1)]

    evaluator = util.Evaluator(model, test_data_container,
                               checkpoint_file, preprocessor)

    # For the inputted checkpoint, compute the overall test accuracy
    accuracies = []
    print 'Checkpoint: %s' % os.path.split(checkpoint_file)[1]
    evaluator.set_checkpoint(checkpoint_file)
    accuracy = evaluator.run()
Exemple #2
0
                        help='Folder containing all .pkl checkpoint files.')
    args = parser.parse_args()

    checkpoint_dir = args.checkpoint_dir
    fold = int(args.split)
    dataset_path = os.path.join(data_paths.tfd_data_path, 'npy_files/TFD_96/split_'+str(fold))

    print 'Checkpoint directory: %s' % checkpoint_dir
    print 'Testing on split %d\n' % fold

    # Load model
    model = SupervisedModel('evaluation', './')

    # Load data
    supervised_data_loader = SupervisedDataLoader(dataset_path)
    val_data_container = supervised_data_loader.load(1)
    val_data_container.X = numpy.float32(val_data_container.X)
    val_data_container.X /= 255.0
    val_data_container.X *= 2.0

    # Construct evaluator
    preprocessor = [util.Normer3(filter_size=5, num_channels=1)]

    checkpoint_file_list = sorted(
        glob.glob(os.path.join(checkpoint_dir, '*.pkl')))
    evaluator = util.Evaluator(model, val_data_container,
                               checkpoint_file_list[0], preprocessor)

    # For each checkpoint, compute the overall val accuracy
    accuracies = []
    for checkpoint in checkpoint_file_list:
Exemple #3
0
# Load model
model = SupervisedModel('experiment', './', learning_rate=1e-2)
monitor = util.Monitor(model,
                       checkpoint_directory='checkpoints_'+str(train_split),
                       save_steps=1000)

# Add dropout flag to fully-connected layer
model.fc4.dropout = 0.5
model._compile()

# Loading TFD dataset
print('Loading Data')
supervised_data_loader = SupervisedDataLoader(
    os.path.join(data_paths.tfd_data_path, 'npy_files/TFD_96/split_'+str(train_split)))
train_data_container = supervised_data_loader.load(0)
val_data_container = supervised_data_loader.load(1)
test_data_container = supervised_data_loader.load(2)

X_train = train_data_container.X
y_train = train_data_container.y
X_val = val_data_container.X
y_val = val_data_container.y
X_test = test_data_container.X
y_test = test_data_container.y

X_train = numpy.float32(X_train)
X_train /= 255.0
X_train *= 2.0

X_val = numpy.float32(X_val)
        set_num = 0
    elif args.which_set == 'val':
        set_num = 1
    else:
        set_num = 2

    print 'Checkpoint: %s' % checkpoint_file
    print 'Evaluating on split %d' % fold
    print 'Using %s set\n' % args.which_set    

    # Load model
    model = SupervisedModel('evaluation', './')

    # Load dataset
    supervised_data_loader = SupervisedDataLoader(dataset_path)
    data_container = supervised_data_loader.load(set_num)
    data_container.X = numpy.float32(data_container.X)
    data_container.X /= 255.0
    data_container.X *= 2.0
    print data_container.X.shape

    # Construct evaluator
    preprocessor = [util.Normer3(filter_size=5, num_channels=1)]

    evaluator = util.Evaluator(model, data_container,
                               checkpoint_file, preprocessor)

    # For the inputted checkpoint, compute the overall accuracy
    accuracies = []
    print 'Checkpoint: %s' % os.path.split(checkpoint_file)[1]
    evaluator.set_checkpoint(checkpoint_file)