Esempio n. 1
0
def get_opt():

    opt = Namespace()
    # Model
    opt.CAPACITY = 32
    opt.NUM_COMPONENTS = 10
    opt.GMM_NUM_COMPONENTS = 10
    # Training
    opt.LR = 0.001
    opt.NUM_ITER = 3000
    opt.CUDA = True
    opt.REC_FREQ = 10
    # Meta
    opt.ALPHA_LR = 0.1
    # opt.ALPHA_NUM_ITER = 500
    # opt.ALPHA_NUM_ITER = 50
    opt.ALPHA_NUM_ITER = 10
    opt.FINETUNE_LR = 0.001
    opt.FINETUNE_NUM_ITER = 10
    opt.PARAM_DISTRY = lambda mean: normal(mean, 2, opt.NUM_SAMPLES)
    opt.PARAM_SAMPLER = lambda: np.random.uniform(-4, 4)
    # Sampling
    opt.NUM_SAMPLES = 1000
    opt.TRAIN_DISTRY = lambda: normal(0, 2, opt.NUM_SAMPLES)
    opt.TRANS_DISTRY = lambda: normal(random.randint(-4, 4), 2, opt.NUM_SAMPLES
                                      )
    return opt
Esempio n. 2
0
def normal(mean, std, N):
    return torch.normal(torch.ones(N).mul_(mean), torch.ones(N).mul_(std)).view(-1, 1)

opt = Namespace()
# Model
opt.CAPACITY = 32
opt.NUM_COMPONENTS = 10
opt.GMM_NUM_COMPONENTS = 10
# Training
opt.LR = 0.001
opt.NUM_ITER = 3000
opt.CUDA = False
opt.REC_FREQ = 10
# Meta
opt.ALPHA_LR = 0.1
opt.ALPHA_NUM_ITER = 50
opt.FINETUNE_LR = 0.001
opt.FINETUNE_NUM_ITER = 10
opt.PARAM_DISTRY = lambda mean: normal(mean, 2, opt.NUM_TRANS_SAMPLES)
opt.PARAM_SAMPLER = lambda: np.random.uniform(-4, 4)
# Sampling
opt.NUM_SAMPLES = 1000
opt.NUM_TRANS_SAMPLES = 1000
opt.TRAIN_DISTRY = lambda: normal(0, 2, opt.NUM_SAMPLES)
opt.TRAIN_EVAL_DISTRY = lambda: normal(0, 2, 10000)
#opt.TRANS_DISTRY = lambda: normal(random.randint(-4, 4), 2, opt.NUM_SAMPLES)

alpha_list = []
beta_list = []
gamma_list = []
iterations = 100