Exemple #1
0
model = BSC_ET(D, H, Hprime, gamma, to_learn=['W','sigma','pi','mu'])

data = {'y':patches}


out_fname = output_path + "/data.h5"


#setting up logging/output
print_list = ('T', 'Q', 'pi', 'sigma', 'N', 'MAE', 'L')
dlog.set_handler(print_list, TextPrinter)
h5store_list = ('W', 'pi', 'sigma', 'y', 'MAE', 'N','L','Q','mu')
dlog.set_handler(h5store_list, StoreToH5, output_path +'/result.h5')

###### Initialize model #######
# Initialize (Random) model parameters
model_params = model.standard_init(data)

#model_params['mu'] = np.mean(data['y'],axis=0)

# Create and start EM annealing
em = EM(model=model, anneal=anneal)
em.data = data
em.lparams = model_params
em.run()

dlog.close(True)
pprint("Done")


Exemple #2
0
    #As a control, we also append the initial values
    dlog.append_all( {
        'W' : lparams['W'], 
        'pi': lparams['pi'],
        'sigma': lparams['sigma'],
    } )

comm.Barrier()

#==================== Create and run EM =====================================
dlog.progress("Starting EM")

em = EM(model=model, anneal=anneal)
em.data =  {'y': my_y, 'y_rc': my_y_rc}
em.lparams = lparams
em.run(verbose=True)
lparams = em.lparams

#dlog.close()
comm.Barrier()

#============================================================================
# Extract final generative fields (W)

if lparams.has_key("rev_corr") and lparams['rev_corr'].max() > 1e-7:
    dlog.progress("Using actual reverse correlated fields")
    RF = lparams["rev_corr"]

    H, D  = RF.shape

   # Undo channel splitting
Exemple #3
0
    #As a control, we also append the initial values
    dlog.append_all({
        'W': lparams['W'],
        'pi': lparams['pi'],
        'sigma': lparams['sigma'],
    })

comm.Barrier()

#==================== Create and run EM =====================================
dlog.progress("Starting EM")

em = EM(model=model, anneal=anneal)
em.data = {'y': my_y, 'y_rc': my_y_rc}
em.lparams = lparams
em.run(verbose=True)
lparams = em.lparams

#dlog.close()
comm.Barrier()

#============================================================================
# Extract final generative fields (W)

if lparams.has_key("rev_corr") and lparams['rev_corr'].max() > 1e-7:
    dlog.progress("Using actual reverse correlated fields")
    RF = lparams["rev_corr"]

    H, D = RF.shape

    # Undo channel splitting
Exemple #4
0
    if W_learn == 'mean':
        lparams = {
            'W': mean_W,
            'pi': pi_learn,
            'sigma': sigma_learn,
            'mu': mu_learn
        }
    elif W_learn == 'ground_truth':
        lparams = {'W': W_gt, 'pi': pi_gt, 'sigma': sigma_gt, 'mu': mu_gt}
    else:
        lparams = {
            'W': W_learn,
            'pi': pi_learn,
            'sigma': sigma_learn,
            'mu': mu_learn
        }
    lparams = model.noisify_params(lparams, anneal)

    # Create and start EM annealing
    em = EM(model=model, anneal=anneal)
    em.data = my_data
    em.lparams = lparams
    em.run()
    pprint("Done with ET, Calculating MAE...")
    MAE = check_basis(em.lparams['W'], W_gt)
    if MAE == None:
        MAE = np.inf
    dlog.append('MAE', MAE[0])
    dlog.close(True)
    pprint("Done")