#extracting variables Motion = mat_dict['Motion']; #setting CRBM parameters L1Config = {}; L1Config['n_visible'] = Motion[0,0].shape[1]; L1Config['n_hidden'] = 150; L1Config['delay'] = 3; L1Config['learning_rate'] = 1e-3; L1Config['training_epochs'] = 200; L1Config['batch_size'] = 100; #train CRBM and sample hidden giving visible crbm1, batchdata_l1 = CO.train_crbm(L1Config, batchdata1, seqlen1, data_mean1, data_std1); #save the layer 1 crbm1 L1Config['data_mean'] = data_mean1; L1Config['data_std'] = data_std1; L1Config['model'] = {'A':crbm1.A.get_value(), 'B':crbm1.B.get_value(), 'W':crbm1.W.get_value(), 'hbias':crbm1.hbias.get_value(),'vbias':crbm1.vbias.get_value()}; scipy.io.savemat('crbmconfig_1.mat',{'PyCRBMConfig':L1Config}); # put together the features for each input sequence Feat1 = np.ndarray(shape=(1,9), dtype='O'); for idx, data in enumerate(Motion[0]): Feat1[0,idx] = sample_h_v(data, crbm1, L1Config); #setting CRBM parameters
# coding: utf-8 import crbm as CO import pickle import scipy crbm, batchdata = CO.train_crbm() # Just dumping the model for further use in Python with open('crbmconfig_sean_100h_3p.pkl', 'wb') as output: pickle.dump(crbm, output, pickle.HIGHEST_PROTOCOL) #scipy.io.savemat('crbmconfig_sean_100h_3p.mat',{'A':crbm.A, 'B':crbm.B, 'W':crbm.W, 'hbias':crbm.hbias,'vbias':crbm.vbias}) scipy.io.savemat('crbmconfig_sean_100h_3p.mat',{'A':crbm.A.get_value(), 'B':crbm.B.get_value(), 'W':crbm.W.get_value(), 'hbias':crbm.hbias.get_value(),'vbias':crbm.vbias.get_value()})
#extracting variables Motion = mat_dict['Motion'] #setting CRBM parameters L1Config = {} L1Config['n_visible'] = Motion[0, 0].shape[1] L1Config['n_hidden'] = 150 L1Config['delay'] = 3 L1Config['learning_rate'] = 1e-3 L1Config['training_epochs'] = 200 L1Config['batch_size'] = 100 #train CRBM and sample hidden giving visible crbm1, batchdata_l1 = CO.train_crbm(L1Config, batchdata1, seqlen1, data_mean1, data_std1) #save the layer 1 crbm1 L1Config['data_mean'] = data_mean1 L1Config['data_std'] = data_std1 L1Config['model'] = { 'A': crbm1.A.get_value(), 'B': crbm1.B.get_value(), 'W': crbm1.W.get_value(), 'hbias': crbm1.hbias.get_value(), 'vbias': crbm1.vbias.get_value() } scipy.io.savemat('crbmconfig_1.mat', {'PyCRBMConfig': L1Config}) # put together the features for each input sequence Feat1 = np.ndarray(shape=(1, 9), dtype='O')