Пример #1
0
EPSILON = 0.05  # label threshold
BATCH_SIZE = 100  # batch size for both labeled and unlabeled data
""" Percentage of the unlabeled data to be used. If 1.0, entire training data
    is used. """
UNLAB_RAT = 1.0
# determines the deviation of the noise added to weights
LANGEVIN_COEF = 10**-5
MOMENTUM = 0.9
WEIGHT_DECAY = 0

# setup directories and set dataset/net_name dependent parameters:
NB_LABELLED = 4000
NB_OUTER_ITER = 135
NB_INNER_ITER = 20
nb_outer_start = 0
net_w_orig = ResNet18().cuda()
file_name = '%s_%s' % (DATASET, NET_NAME)
unsup_nll_loss = unsup_nll(BATCH_SIZE)

for path in [PLOT_FOLDER, Y_U_FOLDER]:
    if not os.path.exists(path):
        os.makedirs(path)

# load dataloaders:
loaders = get_loaders(NB_LABELLED, BATCH_SIZE, UNLAB_RAT, AUGMENT_TYPE)
lab_inds = loaders["lab_inds"]
test_set = loaders["test_set"]
testloader = loaders["testloader"]
trainloader_l = loaders["trainloader_l"]
trainloader_u = loaders["trainloader_u"]
trainset_l = loaders["trainset_l"]
Пример #2
0
EPSILON = 0.05  # label threshold
BATCH_SIZE = 100  # batch size for both labeled and unlabeled data
""" Percentage of the unlabeled data to be used. If 1.0, entire training data
    is used. """
UNLAB_RAT = 1.0
# determines the deviation of the noise added to weights
LANGEVIN_COEF = 10**-5
MOMENTUM = 0.9
WEIGHT_DECAY = 0

# setup directories and set dataset/net_name dependent parameters:
NB_LABELLED = 1000
NB_OUTER_ITER = 30
NB_INNER_ITER = 10
nb_outer_start = 0
net_w_orig = ResNet18(n=5).cuda()
file_name = '%s_%s' % (DATASET, NET_NAME)
unsup_nll_loss = unsup_nll(BATCH_SIZE)

for path in [PLOT_FOLDER, Y_U_FOLDER]:
    if not os.path.exists(path):
        os.makedirs(path)

# load dataloaders:
loaders = get_loaders(NB_LABELLED, BATCH_SIZE, UNLAB_RAT)
lab_inds = loaders["lab_inds"]
test_set = loaders["test_set"]
testloader = loaders["testloader"]
trainloader_l = loaders["trainloader_l"]
trainloader_u = loaders["trainloader_u"]
trainset_l = loaders["trainset_l"]