Esempio n. 1
0
from configuration.train_configuration import TrainConfiguration
from data_loading.sources.mnist_source import MNISTSource
from data_loading.loaders.autoencoder_loader import AutoEncoderLoader
from data_loading.loaders.multi_loader import MultiLoader
import torch.optim as optim
import torch.nn as nn
from networks.autoencoder import AutoEncoder
import random


def get_loader():
    source = MNISTSource('/home/ray/Data/MNIST')
    loader_params = {'crop_size': [28, 28]}
    return AutoEncoderLoader(source, loader_params)


loader = (get_loader, dict())
# loader = (MultiLoader,dict(loader=get_loader,loader_args=dict(),num_procs=16))
model = (AutoEncoder, dict(inchans=1))
optimizer = (optim.Adam, dict(lr=1e-3))
loss = nn.BCELoss()
train_config = TrainConfiguration(loader, optimizer, model, loss, False)
Esempio n. 2
0
import random


def get_loader(mode):
    path = '/home/ray/Data/KITTI/testing' if mode == 'test' else '/home/ray/Data/KITTI/training'
    source = KITTISource(path, max_frames=10000)
    return TripletDetectionLoader(source,
                                  crop_size=[255, 255],
                                  anchor_size=[127, 127],
                                  obj_types=['Car'],
                                  mode=mode)


loader_test = (MultiLoader,
               dict(loader=get_loader,
                    loader_args=dict(mode='test'),
                    num_procs=1))
loader_train = (MultiLoader,
                dict(loader=get_loader,
                     loader_args=dict(mode='train'),
                     num_procs=1))
model = (TripletCorrelationalDetector, dict())
optimizer = (optim.Adam, dict(lr=1e-4))
loss = triplet_correlation_loss2
train_config = TrainConfiguration(loader_train,
                                  optimizer,
                                  model,
                                  loss,
                                  cuda=True)
test_config = TestConfiguration(loader_test, model, loss, cuda=True)