<s> """<STR_LIT>""" <EOL> from neon import NervanaObject <EOL> from neon . util . argparser import NeonArgparser <EOL> from neon . initializers import Xavier <EOL> from neon . layers import Conv , Pooling , GeneralizedCost , Affine , MergeBroadcast <EOL> from neon . optimizers import GradientDescentMomentum , MultiOptimizer , Schedule <EOL> from neon . transforms import Rectlin , CrossEntropyMulti <EOL> from neon . models import Model <EOL> from neon . data import ArrayIterator <EOL> import numpy as np <EOL> parser = NeonArgparser ( __doc__ ) <EOL> args = parser . parse_args ( ) <EOL> NervanaObject . be . enable_winograd = <NUM_LIT:4> <EOL> X_train = np . random . uniform ( - <NUM_LIT:1> , <NUM_LIT:1> , ( <NUM_LIT> , <NUM_LIT:3> * <NUM_LIT> * <NUM_LIT> ) ) <EOL> y_train = np . random . uniform ( - <NUM_LIT:1> , <NUM_LIT:1> , ( <NUM_LIT> , <NUM_LIT:1000> ) ) <EOL> train = ArrayIterator ( X_train , y_train , nclass = <NUM_LIT:1000> , lshape = ( <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> init1 = Xavier ( local = False ) <EOL> initx = Xavier ( local = True ) <EOL> relu = Rectlin ( ) <EOL> common = dict ( activation = relu , init = initx ) <EOL> commonp1 = dict ( activation = relu , init = initx , padding = <NUM_LIT:1> ) <EOL> commonp2 = dict ( activation = relu , init = initx , padding = <NUM_LIT:2> ) <EOL> pool3s1p1 = dict ( fshape = <NUM_LIT:3> , padding = <NUM_LIT:1> , strides = <NUM_LIT:1> ) <EOL> pool3s2p1 = dict ( fshape = <NUM_LIT:3> , padding = <NUM_LIT:1> , strides = <NUM_LIT:2> , op = '<STR_LIT>' ) <EOL> def inception ( kvals ) : <EOL> ( p1 , p2 , p3 , p4 ) = kvals <EOL> branch1 = [ Conv ( ( <NUM_LIT:1> , <NUM_LIT:1> , p1 [ <NUM_LIT:0> ] ) , ** common ) ] <EOL> branch2 = [ Conv ( ( <NUM_LIT:1> , <NUM_LIT:1> , p2 [ <NUM_LIT:0> ] ) , ** common ) , Conv ( ( <NUM_LIT:3> , <NUM_LIT:3> , p2 [ <NUM_LIT:1> ] ) , ** commonp1 ) ] <EOL> branch3 = [ Conv ( ( <NUM_LIT:1> , <NUM_LIT:1> , p3 [ <NUM_LIT:0> ] ) , ** common ) , Conv ( ( <NUM_LIT:5> , <NUM_LIT:5> , p3 [ <NUM_LIT:1> ] ) , ** commonp2 ) ] <EOL> branch4 = [ Pooling ( op = "<STR_LIT>" , ** pool3s1p1 ) , Conv ( ( <NUM_LIT:1> , <NUM_LIT:1> , p4 [ <NUM_LIT:0> ] ) , ** common ) ] <EOL> return MergeBroadcast ( layers = [ branch1 , branch2 , branch3 , branch4 ] , merge = "<STR_LIT>" ) <EOL> model = Model ( layers = [ <EOL> Conv ( ( <NUM_LIT:7> , <NUM_LIT:7> , <NUM_LIT:64> ) , padding = <NUM_LIT:3> , strides = <NUM_LIT:2> , ** common ) , <EOL> Pooling ( ** pool3s2p1 ) , <EOL> Conv ( ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:64> ) , ** common ) , <EOL> Conv ( ( <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT> ) , ** commonp1 ) , <EOL> Pooling ( ** pool3s2p1 ) , <EOL> inception ( [ ( <NUM_LIT:64> , ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:16> , <NUM_LIT:32> ) , ( <NUM_LIT:32> , ) ] ) , <EOL> inception ( [ ( <NUM_LIT> , ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:32> , <NUM_LIT> ) , ( <NUM_LIT:64> , ) ] ) , <EOL> Pooling ( ** pool3s2p1 ) , <EOL> inception ( [ ( <NUM_LIT> , ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:16> , <NUM_LIT> ) , ( <NUM_LIT:64> , ) ] ) , <EOL> inception ( [ ( <NUM_LIT> , ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT:64> ) , ( <NUM_LIT:64> , ) ] ) , <EOL> inception ( [ ( <NUM_LIT> , ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT:64> ) , ( <NUM_LIT:64> , ) ] ) , <EOL> inception ( [ ( <NUM_LIT> , ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:32> , <NUM_LIT:64> ) , ( <NUM_LIT:64> , ) ] ) , <EOL> inception ( [ ( <NUM_LIT> , ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:32> , <NUM_LIT> ) , ( <NUM_LIT> , ) ] ) , <EOL> Pooling ( ** pool3s2p1 ) , <EOL> inception ( [ ( <NUM_LIT> , ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:32> , <NUM_LIT> ) , ( <NUM_LIT> , ) ] ) , <EOL> inception ( [ ( <NUM_LIT> , ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , ) ] ) , <EOL> Pooling ( fshape = <NUM_LIT:7> , strides = <NUM_LIT:1> , op = "<STR_LIT>" ) , <EOL> Affine ( nout = <NUM_LIT:1000> , init = init1 ) ] ) <EOL> weight_sched = Schedule ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , ( <NUM_LIT:1> / <NUM_LIT> ) ** ( <NUM_LIT:1> / <NUM_LIT> ) ) <EOL> opt_gdm = GradientDescentMomentum ( <NUM_LIT> , <NUM_LIT:0.0> , wdecay = <NUM_LIT> , schedule = weight_sched ) <EOL> opt = MultiOptimizer ( { '<STR_LIT:default>' : opt_gdm } ) <EOL> cost = GeneralizedCost ( costfunc = CrossEntropyMulti ( ) ) <EOL> model . benchmark ( train , cost = cost , optimizer = opt , niterations = <NUM_LIT:10> , nskip = <NUM_LIT:1> ) </s>
