Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

CNNArch.mc4 4.72 KB
Newer Older
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
1
package de.monticore.lang.monticar;
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
2 3 4

grammar CNNArch extends de.monticore.common.Common {

5 6 7 8 9 10 11
    symbol scope Architecture = "architecture"
                                 name:Name& "("
                                 inputPort:Name& ")" "{"
                                 (MainLayer)+
                                 outputPort:Name& "="
                                 OutputLayer
                                 "}";
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97

    interface Layer;
    ast Layer = method ASTMethod getMethod(){};
    interface Method;
    interface MainLayerMethod extends Method;
    interface OutputLayerMethod extends Method;

    interface ArgumentAssignment;
    ast ArgumentAssignment = method public Enum getLhs(){}
                             method public ASTRhs getRhs(){};

    Rhs = stringVal:String
        | intVal:Num_Int
        | doubleVal:Num_Double
        | intTuple:IntTuple
        | refOrBool:Name;
    IntTuple = "(" values:Num_Int "," values:(Num_Int || ",")+ ")";



    MainLayer implements Layer = method:MainLayerMethod;
    OutputLayer implements Layer = method:OutputLayerMethod;



    ConvolutionMethod implements MainLayerMethod = name:"Convolution" "(" arguments:(ConvolutionArgumentAssignment || ",")* ")";
    ConvolutionArgumentAssignment implements ArgumentAssignment = lhs:ConvolutionArgument "=" rhs:Rhs;
    enum ConvolutionArgument = KERNEL:"kernel"               //required
                             | NUMFILTER:"num_filter"        //required
                             | STRIDE:"stride"
                             | PAD:"pad"
                             | NOBIAS:"no_bias";

    FullyConnectedMethod implements MainLayerMethod = name:"FullyConnected" "(" arguments:(FullyConnectedArgumentAssignment || ",")* ")";
    FullyConnectedArgumentAssignment implements ArgumentAssignment = lhs:FullyConnectedArgument "=" rhs:Rhs;
    enum FullyConnectedArgument = NUMHIDDEN:"num_hidden"     //required
                                | NOBIAS:"no_bias";

    ActivationMethod implements MainLayerMethod = name:"Activation" "(" arguments:(ActivationArgumentAssignment || ",")* ")";
    ActivationArgumentAssignment implements ArgumentAssignment = lhs:ActivationArgument "=" rhs:Rhs;
    enum ActivationArgument = ACTTYPE:"act_type";            //required

    PoolingMethod implements MainLayerMethod = name:"Pooling" "(" arguments:(PoolingArgumentAssignment || ",")* ")";
    PoolingArgumentAssignment implements ArgumentAssignment = lhs:PoolingArgument "=" rhs:Rhs;
    enum PoolingArgument = KERNEL:"kernel"                   //required
                         | POOLTYPE:"pool_type"              //required
                         | POOLINGCONVENTION:"pooling_convention"
                         | STRIDE:"stride"
                         | PAD:"pad";

    DropoutMethod implements MainLayerMethod = name:"Dropout" "(" arguments:(DropoutArgumentAssignment || ",")* ")";
    DropoutArgumentAssignment implements ArgumentAssignment = lhs:DropoutArgument "=" rhs:Rhs;
    enum DropoutArgument = P:"p"
                         | MODE:"mode";

    LRNMethod implements MainLayerMethod = name:"LRN" "(" arguments:(LRNArgumentAssignment || ",")* ")";
    LRNArgumentAssignment implements ArgumentAssignment = lhs:LRNArgument "=" rhs:Rhs;
    enum LRNArgument = ALPHA:"alpha"
                     | BETA:"beta"
                     | KNORM:"knorm"
                     | NSIZE:"nsize";                         //required

    FlattenMethod implements MainLayerMethod = name:"Flatten" "(" ")";




    StandardOutputLayerMethod implements OutputLayerMethod = (optName:"SoftmaxOutput"
                                                           | optName:"MAERegressionOutput"
                                                           | optName:"LinearRegressionOutput"
                                                           | optName:"LogisticRegressionOutput") "("
                                                             arguments:(StandardOutputArgumentAssignment || ",")* ")";
    ast StandardOutputLayerMethod = method public String getName(){
                                          return optName.get();
                                      };
    StandardOutputArgumentAssignment implements ArgumentAssignment = lhs:StandardOutputArgument "=" rhs:Rhs;
    enum StandardOutputArgument = GRADSCALE:"grad_scale";


    SVMOutputLayerMethod implements OutputLayerMethod = name:"SVMOutput" "("
                                                            arguments:(SVMOutputArgumentAssignment || ",")* ")";
    SVMOutputArgumentAssignment implements ArgumentAssignment = lhs:SVMOutputArgument "=" rhs:Rhs;
    enum SVMOutputArgument = MARGIN:"margin"
                           | REGULARIZATIONCOEFFICIENT:"regularization_coefficient"
                           | USELINEAR:"use_linear";
}