-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.m
76 lines (56 loc) · 2.01 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
%% Pretrainineg Three Stacked layer of 3D-CAE on Brain MRI
% Ehsan Hosseini-Asl
% University of Louisville
% December 15, 2015
clear all; close all; clc;
addpath('util')
%% load 3D Brain MRI;
load('3d_MRI.mat')
x = cell(1, 1);
x{1}{1} = volume;
x{1}{2} = volume;
y = [0,1;
1,0];
%% Building 3 layers of Stacked 3D-CAE
filter_No = 5;
filter_size = [3 3 3];
noise = 0.0;
scae = {
struct('outputmaps', filter_No, 'inputkernel', filter_size, 'outputkernel', filter_size, 'scale', [2 2 2], 'sigma', 0.1, 'momentum', 0.9, 'noise', noise)
struct('outputmaps', filter_No, 'inputkernel', filter_size, 'outputkernel', filter_size, 'scale', [2 2 2], 'sigma', 0.1, 'momentum', 0.9, 'noise', noise)
struct('outputmaps', filter_No, 'inputkernel', filter_size, 'outputkernel', filter_size, 'scale', [2 2 2], 'sigma', 0.1, 'momentum', 0.9, 'noise', noise)
};
% opts.rounds = 20;
opts.rounds = 1;
opts.epoc = 1;
opts.batchsize = 1;
opts.trainsize = 2;
opts.alpha = 0.01;
opts.ddinterval = 10;
opts.ddhist = 0.5;
scae = scaesetup_3d(scae, x{1}{1}, opts);
dbstop if error
%% Training 3D-SCAE
scae = scaetrain_3d(scae, x, opts);
%% initialize CNN
addpath('/Users/Ehsan/Dropbox/Codes/Deep Learning/DeepLearnToolbox/CNN')
cnn.layers = {
struct('type', 'i') %input layer
struct('type', 'c', 'outputmaps', filter_No, 'kernelsize', filter_size(1)) %convolution layer
struct('type', 's', 'scale', 2) %sub sampling layer
struct('type', 'c', 'outputmaps', filter_No, 'kernelsize', filter_size(1)) %convolution layer
struct('type', 's', 'scale', 2) %subsampling layer
struct('type', 'c', 'outputmaps', filter_No, 'kernelsize', filter_size(1)) %convolution layer
struct('type', 's', 'scale', 2) %subsampling layer
};
opts.alpha = 0.001;
opts.batchsize = 1;
opts.numepochs = 10;
cnn = cnnsetup_3d(cnn, x{1}, y,scae);
%%
% mask = x{1}{1};
% mask(mask~=0)=1;
% train_mask{1} = mask;
cnn = cnntrain_3d(cnn, x{1}, y, opts);
%%
[er, bad, output] = cnntest_3d(cnn, x, y);