#                     'qv_arch': [[x_size,200],[200,200],[200,z_size*2]],
#                     'qz_arch': [[x_size+z_size,200],[200,200],[200,z_size*2]],
#                     'rv_arch': [[x_size+z_size,200],[200,200],[200,z_size*2]],
#                     'flow_hidden_size': 100
#                 }

#     # model = VAE(hyper_config)



# else:
#     print ('What')
#     fadas


trained_model = VAE(hyper_config)
# model.load_params(home+'/Documents/tmp/first_try/'+args.model+'/params_'+args.model+'_2800.pt')
trained_model.load_params(home+'/Documents/tmp/new_training/standard/params_standard_1000.pt')


# now to reset encoder, or even load a new one with different architecture. 
# could maybe init a new one. and get model to ignore the old one. 
# antoher option is init the right model then just load the params you want 
# dont init q
# how does it know which params are the decoder ones, besides shape?
    #ah they have keys names! mine are mostly numbers
    
# # print (model.state_dict())


Beispiel #2
0
        hyper_config = {
            'x_size':
            x_size,
            'z_size':
            z_size,
            'act_func':
            F.tanh,  # F.relu,
            'encoder_arch': [[x_size, l_size], [l_size, l_size],
                             [l_size, z_size * 2]],
            'decoder_arch': [[z_size, l_size], [l_size, l_size],
                             [l_size, x_size]],
            'q_dist':
            standard,  #hnf,#aux_nf,#flow1,#,
        }

        model = VAE(hyper_config)

        path_to_save_variables = this_dir + '/params_standard' + '_'

    # elif args.model == 'flow1':

    #     this_dir = directory+'/flow1'
    #     # if not os.path.exists(this_dir):
    #     #     os.makedirs(this_dir)
    #     #     print ('Made directory:'+this_dir)

    #     # experiment_log = this_dir+'/log.txt'

    #     # with open(experiment_log, "a") as myfile:
    #     #     myfile.write("Flow1" +'\n')
    which_model = 'standard'


    if which_model == 'standard':
        print(which_model)
        this_dir = directory+'/standard'    
        hyper_config = { 
                        'x_size': x_size,
                        'z_size': z_size,
                        'act_func': F.tanh,# F.relu,
                        'encoder_arch': [[x_size,l_size],[l_size,l_size],[l_size,z_size*2]],
                        'decoder_arch': [[z_size,l_size],[l_size,l_size],[l_size,x_size]],
                        'q_dist': standard,#hnf,#aux_nf,#flow1,#,
                    }

        model = VAE(hyper_config)

        path_to_save_variables=this_dir+'/params_standard' +'_'






    # elif args.model == 'flow1':

    #     this_dir = directory+'/flow1'
    #     # if not os.path.exists(this_dir):
    #     #     os.makedirs(this_dir)
    #     #     print ('Made directory:'+this_dir)
Beispiel #4
0
#                     'decoder_arch': [[z_size,200],[200,200],[200,x_size]],
#                     'q_dist': hnf,#aux_nf,#flow1,#standard,#, #, #, #,#, #,# ,
#                     'n_flows': 2,
#                     'qv_arch': [[x_size,200],[200,200],[200,z_size*2]],
#                     'qz_arch': [[x_size+z_size,200],[200,200],[200,z_size*2]],
#                     'rv_arch': [[x_size+z_size,200],[200,200],[200,z_size*2]],
#                     'flow_hidden_size': 100
#                 }

#     # model = VAE(hyper_config)

else:
    print('What')
    fadas

model = VAE(hyper_config)
print('done init')
model.load_params(home + '/Documents/tmp/large_N_time/' + args.model +
                  '/params_' + args.model + '_1.pt')

#Train params
learning_rate = .001
batch_size = 100
k = 1
epochs = 3000

#save params and compute IW and AIS
start_at = 100
save_freq = 300
display_epoch = 10
        # with open(experiment_log, "a") as myfile:
        #     myfile.write("Standard" +'\n')

        print('Init standard model')

        hyper_config = {
            'x_size': x_size,
            'z_size': z_size,
            'act_func': F.tanh,  # F.relu,
            'encoder_arch': [[x_size, 200], [200, 200], [200, z_size * 2]],
            'decoder_arch': [[z_size, 200], [200, 200], [200, x_size]],
            'q_dist': standard_layernorm  #standard,#hnf,#aux_nf,#flow1,#,
        }

        model = VAE(hyper_config)

    # elif model_ == 'flow1':

    #     this_dir = directory+'/flow1'
    #     if not os.path.exists(this_dir):
    #         os.makedirs(this_dir)
    #         print ('Made directory:'+this_dir)

    #     experiment_log = this_dir+eval_file

    #     with open(experiment_log, "a") as myfile:
    #         myfile.write("Flow1" +'\n')

    #     print('Init flow model')
    #     hyper_config = {
Beispiel #6
0
                    'qv_arch': [[x_size,200],[200,200],[200,z_size*2]],
                    'qz_arch': [[x_size+z_size,200],[200,200],[200,z_size*2]],
                    'rv_arch': [[x_size+z_size,200],[200,200],[200,z_size*2]],
                    'flow_hidden_size': 100
                }

    # model = VAE(hyper_config)



else:
    print ('What')
    fadas


model = VAE(hyper_config)
# model.load_params(home+'/Documents/tmp/first_try/'+args.model+'/params_'+args.model+'_2800.pt')



#Train params
# learning_rate = .001
batch_size = 50
k = 1
# epochs = 3000

#save params and compute IW and AIS
start_at = 100
save_freq = 300
display_epoch = 10
#                     'decoder_arch': [[z_size,200],[200,200],[200,x_size]],
#                     'q_dist': aux_nf,#aux_nf,#flow1,#standard,#, #, #, #,#, #,# ,
#                     'n_flows': 2,
#                     'qv_arch': [[x_size,200],[200,200],[200,z_size*2]],
#                     'qz_arch': [[x_size+z_size,200],[200,200],[200,z_size*2]],
#                     'rv_arch': [[x_size+z_size,200],[200,200],[200,z_size*2]],
#                     'flow_hidden_size': 100
#                 }

#     # model = VAE(hyper_config)

# else:
#     print ('What')
#     fadas

trained_model = VAE(hyper_config)
# model.load_params(home+'/Documents/tmp/first_try/'+args.model+'/params_'+args.model+'_2800.pt')
trained_model.load_params(
    home + '/Documents/tmp/new_training/standard/params_standard_1000.pt')

# now to reset encoder, or even load a new one with different architecture.
# could maybe init a new one. and get model to ignore the old one.
# antoher option is init the right model then just load the params you want
# dont init q
# how does it know which params are the decoder ones, besides shape?
#ah they have keys names! mine are mostly numbers

# # print (model.state_dict())

# print (model.state_dict().keys())
# fsdaas
        #     myfile.write("Standard" +'\n')
        


        print('Init standard model')
        
        hyper_config = { 
                        'x_size': x_size,
                        'z_size': z_size,
                        'act_func': F.tanh,# F.relu,
                        'encoder_arch': [[x_size,200],[200,200],[200,z_size*2]],
                        'decoder_arch': [[z_size,200],[200,200],[200,x_size]],
                        'q_dist': standard_layernorm #standard,#hnf,#aux_nf,#flow1,#,
                    }

        model = VAE(hyper_config)



    # elif model_ == 'flow1':

    #     this_dir = directory+'/flow1'
    #     if not os.path.exists(this_dir):
    #         os.makedirs(this_dir)
    #         print ('Made directory:'+this_dir)

    #     experiment_log = this_dir+eval_file

    #     with open(experiment_log, "a") as myfile:
    #         myfile.write("Flow1" +'\n')
        hyper_config = {
            'x_size':
            x_size,
            'z_size':
            z_size,
            'act_func':
            F.tanh,  # F.relu,
            'encoder_arch': [[x_size, l_size], [l_size, l_size],
                             [l_size, z_size * 2]],
            'decoder_arch': [[z_size, l_size], [l_size, l_size],
                             [l_size, x_size]],
            'q_dist':
            standard,  #hnf,#aux_nf,#flow1,#,
        }

        model = VAE(hyper_config)

    elif model_ == 'flow1':

        this_dir = directory + '/flow1'
        if not os.path.exists(this_dir):
            os.makedirs(this_dir)
            print('Made directory:' + this_dir)

        experiment_log = this_dir + eval_file

        with open(experiment_log, "a") as myfile:
            myfile.write("Flow1" + '\n')

        print('Init flow model')
        hyper_config = {
        myfile.write("Standard" +'\n')
    


    print('Init standard model')
    
    hyper_config = { 
                    'x_size': x_size,
                    'z_size': z_size,
                    'act_func': F.tanh,# F.relu,
                    'encoder_arch': [[x_size,200],[200,200],[200,z_size*2]],
                    'decoder_arch': [[z_size,200],[200,200],[200,x_size]],
                    'q_dist': standard,#hnf,#aux_nf,#flow1,#,
                }

    model = VAE(hyper_config)



elif args.model == 'flow1':

    this_dir = directory+'/flow1'
    if not os.path.exists(this_dir):
        os.makedirs(this_dir)
        print ('Made directory:'+this_dir)

    experiment_log = this_dir+eval_file

    with open(experiment_log, "a") as myfile:
        myfile.write("Flow1" +'\n')
#                     'q_dist': hnf,#aux_nf,#flow1,#standard,#, #, #, #,#, #,# ,
#                     'n_flows': 2,
#                     'qv_arch': [[x_size,200],[200,200],[200,z_size*2]],
#                     'qz_arch': [[x_size+z_size,200],[200,200],[200,z_size*2]],
#                     'rv_arch': [[x_size+z_size,200],[200,200],[200,z_size*2]],
#                     'flow_hidden_size': 100
#                 }

#     # model = VAE(hyper_config)

else:
    print ('What')
    fadas


model = VAE(hyper_config)
print ('done init')
model.load_params(home+'/Documents/tmp/large_N_time/'+args.model+'/params_'+args.model+'_1.pt')



#Train params
learning_rate = .001
batch_size = 100
k = 1
epochs = 3000

#save params and compute IW and AIS
start_at = 100
save_freq = 300
display_epoch = 10