Mercurial > hg > camir-aes2014
comparison toolboxes/RBM/Main.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
2 % Main script of KRBM-Knowledge-based Restricted Boltzmann Machine % | |
3 % -*-sontran2012-*- % | |
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
5 %% loading background knowledge | |
6 % bk_file = 'XOR.bk'; | |
7 % w = 5; | |
8 W = rand(0,0); | |
9 mW = rand(0,0); | |
10 % [W mW nNames] = encode_bk(bk_file,w) | |
11 %%% visualize_system(W,nNames,w,100,100); | |
12 %% Loading data | |
13 PRO_DIR = 'C://Pros/'; | |
14 % dat_file = 'XOR.dat'; | |
15 % dat_file = 'DNA.dat'; | |
16 % train_file = strcat(PRO_DIR,'/Data/ICDAR/digit_train_data.mat'; | |
17 % train_label = strcat(PRO_DIR,'/Data/ICDAR/digit_train_label.mat'; | |
18 % test_file = strcat(PRO_DIR,'/Data/ICDAR/digit_test_data.mat'; | |
19 % test_label = strcat(PRO_DIR,'/Data/ICDAR/digit_test_label.mat'; | |
20 %----------------------------------------------------- | |
21 % train_file = strcat(PRO_DIR,'/Data/MNIST/mnist_train_data.mat'; | |
22 % train_label = strcat(PRO_DIR,'/Data/MNIST/mnist_train_label.mat'; | |
23 % test_file = strcat(PRO_DIR,'/Data/MNIST/mnist_test_data.mat'; | |
24 % test_label = strcat(PRO_DIR,'/Data/MNIST/mnist_test_label.mat'; | |
25 %----------------------------------------------------- | |
26 % train_file = strcat(PRO_DIR,'/RBMLIB/train_dat.mat'); | |
27 % train_label = strcat(PRO_DIR,'/RBMLIB/train_lab.mat'); | |
28 % test_file = strcat(PRO_DIR,'/RBMLIB/test_dat.mat'); | |
29 % test_label = strcat(PRO_DIR,'/RBMLIB/test_lab.mat'); | |
30 %----------------------------------------------------- | |
31 % train_file = strcat(PRO_DIR,'/RBMLIB/train_dat.mat'); | |
32 data_file = strcat(PRO_DIR,'/DATA/XOR/xorall.mat'); | |
33 mod_file = strcat(PRO_DIR,'/DATA/XOR/model.mat'); | |
34 %% Move weights encoded from rule to right position of input if needed | |
35 | |
36 %% Setting parameters | |
37 conf.hidNum = 4; | |
38 conf.eNum = 50; % number of epoch | |
39 conf.bNum = 1; % number of batches devides the data set | |
40 conf.sNum = 4; % number of samples per batch | |
41 conf.gNum = 1; % number of iteration for gibb sampling | |
42 conf.params = [0.5 0.5 0.1 0.00002]; % [lr1 lr2 momentum cost] | |
43 % lr1: learning rate in first 10 epoches | |
44 % lr2: learning rate in the other epoches | |
45 %% Training system | |
46 % training_kbrm(conf,W,mW,dat_file); % unsupevised learning | |
47 % [W visB hidB] = gen_training_kbrbm(conf,W,mW,train_file,train_label); % unsupervised learning for generative classification | |
48 % dis_training_kbrm(conf,W,mW,dat_file,dat_label); % unsupervised learning for discriminative classification | |
49 [W visB hidB] = training_rbm(conf,W,mW,data_file); | |
50 save(mod_file,'W','mW','visB','hidB'); | |
51 nNames = {'X' 'Y' 'Z'}; | |
52 visualize_system(W,nNames,100,100); | |
53 %% Classify (if wanted) | |
54 % gen_classify(W, visB, hidB,mW,test_file,test_label); | |
55 %% Generate features (if wanted) | |
56 % in_f_file = '../Data/ICDAR/images.bin'; | |
57 % out_f_file = '../Data/ICDAR/feature.mat'; | |
58 % input_features = mnist2mat(in_f_file); | |
59 % output_features = input_features*W; | |
60 % save(out_f_file,'output_features'); | |
61 %% Extract knowledge (if wanted) | |
62 % name_file = 'names.txt'; % File contains name of input | |
63 % rule_file = 'rules.txt'; | |
64 % extract_knowledge(rule_file,W); | |
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
66 clear; |