Alexnet.cnna 1.11 KB
Newer Older
1
architecture Alexnet{
2
3
    def input Z(0:255)^{h,w,c} image
    def output Q(0:1)^{classes} predictions
4
5
6
7
    h = 256
    w = 256
    c = 3
    classes = 10
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
8

9
    def conv(filter, channels, hasPool=true, convStride=(1,1)){
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
10
11
        Convolution(kernel=filter, channels=channels, stride=convStride) ->
        Relu() ->
12
        MaxPooling(kernel=(3,3), stride=(2,2), If=hasPool)
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
13
14
15
16
17
18
19
    }
    def fc(){
        FullyConnected(units=4096) ->
        Relu() ->
        Dropout()
    }
    def split1(i, groups){
20
        SplitData(index=i, n=groups) ->
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
21
22
23
24
        conv(filter=(5,5), channels=128) ->
        Lrn(nsize=5, alpha=0.0001, beta=0.75)
    }
    def split2(i, groups){
25
        SplitData(index=i, n=groups) ->
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
26
27
28
        conv(filter=(3,3), channels=192, hasPool=false) ->
        conv(filter=(3,3), channels=128)
    }
29
30

    image ->
31
    conv(filter=(11,11), channels=96, convStride=(4,4)) ->
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
32
33
34
35
    Lrn(nsize=5, alpha=0.0001, beta=0.75) ->
    split1(i=[0|1], groups=2) ->
    conv(filter=(3,3), channels=384 ,hasPool=false) ->
    split2(i=[0|1], groups=2) ->
36
    fc(->=2) ->
37
    FullyConnected(units=classes) ->
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
38
39
40
    Softmax() ->
    predictions
}