from anna import util
from anna.datasets import supervised_dataset

from models import CNNModel

print('Start')

pid = os.getpid()
print('PID: {}'.format(pid))
f = open('pid', 'wb')
f.write(str(pid) + '\n')
f.close()

model = CNNModel('experiment', './', learning_rate=1e-2)
monitor = util.Monitor(model)

# Loading CIFAR-10 dataset
print('Loading Data')
data_path = '/data/cifar10/'
reduced_data_path = os.path.join(data_path, 'reduced', 'cifar10_100')

train_data = numpy.load(os.path.join(reduced_data_path, 'train_X_split_0.npy'))
train_labels = numpy.load(
    os.path.join(reduced_data_path, 'train_y_split_0.npy'))
test_data = numpy.load('/data/cifar10/test_X.npy')
test_labels = numpy.load('/data/cifar10/test_y.npy')

train_dataset = supervised_dataset.SupervisedDataset(train_data, train_labels)
test_dataset = supervised_dataset.SupervisedDataset(test_data, test_labels)
train_iterator = train_dataset.iterator(mode='random_uniform',
checkpoint_dir = os.path.join(args.checkpoint_dir,
                              'checkpoints_48_' + str(test_split))
print 'Checkpoint dir: ', checkpoint_dir

pid = os.getpid()
print('PID: {}'.format(pid))
f = open('pid_' + str(test_split), 'wb')
f.write(str(pid) + '\n')
f.close()

# Load model
model = SupervisedModel('experiment', './', learning_rate=1e-2)
#util.load_checkpoint(model, "./checkpoints_5/experiment-07m-20d-16h-24m-52s.pkl")
monitor = util.Monitor(model,
                       checkpoint_directory=checkpoint_dir,
                       save_steps=1000)

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

# Loading CK+ dataset
print('Loading Data')
#supervised_data_loader = SupervisedDataLoaderCrossVal(
#    data_paths.ck_plus_data_path)
#train_data_container = supervised_data_loader.load('train', train_split)
#test_data_container = supervised_data_loader.load('test', train_split)
train_folds, val_fold, _ = data_fold_loader.load_fold_assignment(
    test_fold=test_split)
X_train, y_train = data_fold_loader.load_folds(data_paths.ck_plus_data_path,
    w = w.transpose(1, 0)
    w = w.reshape(channels, width, height, filters)
    w = numpy.float32(w)
    return w


print('Start')

pid = os.getpid()
print('PID: {}'.format(pid))
f = open('pid', 'wb')
f.write(str(pid) + '\n')
f.close()

model = CAELayer1Model('experiment', './', learning_rate=1e-4)
monitor = util.Monitor(model, save_steps=200)

# Loading CIFAR-10 dataset
print('Loading Data')
train_data = numpy.load('/data/cifar10/train_X.npy')
test_data = numpy.load('/data/cifar10/test_X.npy')

train_dataset = unsupervised_dataset.UnsupervisedDataset(train_data)
test_dataset = unsupervised_dataset.UnsupervisedDataset(test_data)
train_iterator = train_dataset.iterator(mode='random_uniform',
                                        batch_size=128,
                                        num_batches=100000)
test_iterator = test_dataset.iterator(mode='sequential', batch_size=128)

normer = util.Normer2(filter_size=5, num_channels=3)
Пример #4
0
print('Start')
train_split = int(args.split)
if train_split < 0 or train_split > 4:
    raise Exception("Training Split must be in range 0-4.")
print('Using TFD training split: {}'.format(train_split))

pid = os.getpid()
print('PID: {}'.format(pid))
f = open('pid_'+str(train_split), 'wb')
f.write(str(pid)+'\n')
f.close()

# 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
Пример #5
0
train_split = int(args.split)
if train_split < 0 or train_split > 9:
    raise Exception("Training Split must be in range 0-9.")
print('Using STL10 training split: {}'.format(train_split))

pid = os.getpid()
print('PID: {}'.format(pid))
f = open('pid_'+str(train_split), 'wb')
f.write(str(pid)+'\n')
f.close()

model = CNNModel('experiment', './', learning_rate=1e-2)
checkpoint = checkpoints.unsupervised_layer3
util.set_parameters_from_unsupervised_model(model, checkpoint)
monitor = util.Monitor(model,
                       checkpoint_directory='checkpoints_'+str(train_split))

# Loading STL-10 dataset
print('Loading Data')
X_train = numpy.load('/data/stl10_matlab/train_splits/train_X_'
                     + str(train_split)+'.npy')
y_train = numpy.load('/data/stl10_matlab/train_splits/train_y_'
                     + str(train_split)+'.npy')
X_test = numpy.load('/data/stl10_matlab/test_X.npy')
y_test = numpy.load('/data/stl10_matlab/test_y.npy')

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

X_test = numpy.float32(X_test)