Network.emadl 671 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
package cNNCalculator;

component Network<Z(2:oo) classes = 10>{
    ports in Z(0:255)^{3, 32, 32} data,
         out Q(0:1)^{classes} softmax;

    implementation CNN {
        def conv(channels, kernel=1, stride=1){
            Convolution(kernel=(kernel,kernel),channels=channels) ->
            Relu() ->
            Pooling(pool_type="max", kernel=(2,2), stride=(stride,stride))
        }

        data ->
        conv(kernel=5, channels=20, stride=2) ->
        conv(kernel=5, channels=50, stride=2) ->
        FullyConnected(units=500) ->
        Relu() ->
        Dropout() ->
        FullyConnected(units=classes) ->
        Softmax() ->
        softmax
    }
}