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

5
    def conv(filter, channels, hasPool=true, convStride=(1,1)){
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
6
7
        Convolution(kernel=filter, channels=channels, stride=convStride) ->
        Relu() ->
8
        MaxPooling(kernel=(3,3), stride=(2,2), If=hasPool)
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
9
10
11
12
13
14
15
    }
    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 ->
27
    conv(filter=(11,11), channels=96, convStride=(4,4)) ->
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
28
29
30
31
    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) ->
32
    fc(->=2) ->
33
    FullyConnected(units=classes) ->
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
34
35
36
    Softmax() ->
    predictions
}