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

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

    image ->
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
27
28
29
30
31
32
33
34
35
36
    conv(filter=(11,11), channels=96, convStride=4) ->
    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) ->

    fc(_for=[1->2]) ->
37
    FullyConnected(units=classes) ->
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
38
39
40
    Softmax() ->
    predictions
}