CNNTrain.mc4 5.43 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

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
3
grammar CNNTrain extends de.monticore.lang.monticar.Common2, de.monticore.lang.NumberUnit{
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
4

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
5
6
    CNNTrainCompilationUnit = TrainingConfiguration;
    symbol scope TrainingConfiguration = "configuration" name:Name& "{" entries:ConfigEntry* "}";
7

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
8
9
10
11
12
    interface Entry;
    ast Entry = method String getName(){}
                method ASTConfigValue getValue(){};
    interface ConfigValue;
    interface ConfigEntry extends Entry;
13

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
14
15
16
17
18
19
20
21
22
23
24
25
26
    ContextEntry implements ConfigEntry = name:"context" ":" value:ContextValue;
    ModelPathEntry implements ConfigEntry = name:"model_path" ":" value:PathValue;
    TrainDataEntry implements ConfigEntry = name:"train_data" ":" value:DataValue;
    TrainLabelEntry implements ConfigEntry = name:"train_label" ":" value:DataValue;
    TestDataEntry implements ConfigEntry = name:"test_data" ":" value:DataValue;
    TestLabelEntry implements ConfigEntry = name:"test_label" ":" value:DataValue;
    LoadingModeEntry implements ConfigEntry = name:"loading_mode" ":" value:LoadingModeValue;
    OptimizerEntry implements ConfigEntry = name:"optimizer" ":" value:OptimizerValue;
    ValidationSplitEntry implements ConfigEntry = name:"validation_split" ":" value:NumberValue;
    EvalMetricEntry implements ConfigEntry = name:"eval_metric" ":" value:EvalMetricValue;
    NumEpochEntry implements ConfigEntry = name:"num_epoch" ":" value:IntegerValue;
    BatchSizeEntry implements ConfigEntry = name:"batch_size" ":" value:IntegerValue;
    CheckpointEntry implements ConfigEntry = name:"checkpoint" ":" value:IntegerValue;
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
27

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
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
    PathValue implements ConfigValue = path:StringLiteral;
    ContextValue implements ConfigValue = (GPU:"gpu" | CPU:"cpu");
    EvalMetricValue implements ConfigValue =(accuracy:"accuracy"
                                           | crossEntropy:"ce"
                                           | f1:"f1"
                                           | mae:"mae"
                                           | mse:"mse"
                                           | rmse:"rmse"
                                           | topKAccuracy:"top_k_accuracy");
    LRPolicyValue implements ConfigValue =(fixed:"fixed"
                                         | step:"step"
                                         | exp:"exp"
                                         | inv:"inv"
                                         | poly:"poly"
                                         | sigmoid:"sigmoid");
    LoadingModeValue implements ConfigValue =(loadOnly:"load_only"
                                            | loadAndTrain:"load_and_train"
                                            | overwrite:"overwrite"
                                            | noLoad:"no_load");
    DataValue implements ConfigValue = (DataVariable | PathValue);
    DataVariable = Name&;
    IntegerValue implements ConfigValue = Number;
    NumberValue implements ConfigValue = Number;
    BooleanValue implements ConfigValue = (TRUE:"true" | FALSE:"false");

    interface OptimizerValue extends ConfigValue;
    //ast OptimizerValue = method java.util.List<? extends ASTEntry> getParams(){}
    //                     method String getName(){};

    interface SGDEntry extends Entry;
    SGDOptimizer implements OptimizerValue = name:"sgd" ("{" params:SGDEntry* "}")?;

    interface AdamEntry extends Entry;
    AdamOptimizer implements OptimizerValue = name:"adam" ("{" params:AdamEntry* "}")?;

    interface RmsPropEntry extends Entry;
    RmsPropOptimizer implements OptimizerValue = name:"rmsprop" ("{" params:RmsPropEntry* "}")?;

    interface AdaGradEntry extends Entry;
    AdaGradOptimizer implements OptimizerValue = name:"adagrad" ("{" params:AdaGradEntry* "}")?;

    //DCASGD, SGLD, Ftrl, Adamax

    NesterovOptimizer implements OptimizerValue = name:"nag" ("{" params:SGDEntry* "}")?;

    interface AdaDeltaEntry extends Entry;
    AdaDeltaOptimizer implements OptimizerValue = name:"adadelta" ("{" params:AdaDeltaEntry* "}")?;

    interface GeneralOptimizerEntry extends SGDEntry,AdamEntry,RmsPropEntry,AdaGradEntry,AdaDeltaEntry;

    LearningRateEntry implements GeneralOptimizerEntry = name:"learning_rate" ":" value:NumberValue;
    WeightDecayEntry implements GeneralOptimizerEntry = name:"weight_decay" ":" value:NumberValue;
    LRDecayEntry implements GeneralOptimizerEntry = name:"learning_rate_decay" ":" value:NumberValue;
    LRPolicyEntry implements GeneralOptimizerEntry = name:"learning_rate_policy" ":" value:LRPolicyValue;
    RescaleGradEntry implements GeneralOptimizerEntry = name:"rescale_grad" ":" value:NumberValue;
    ClipGradEntry implements GeneralOptimizerEntry = name:"clip_gradient" ":" value:NumberValue;
    StepSizeEntry implements GeneralOptimizerEntry = name:"step_size" ":" value:IntegerValue;


    MomentumEntry implements SGDEntry = name:"momentum" ":" value:NumberValue;
    Beta1Entry implements AdamEntry = name:"beta1" ":" value:NumberValue;
    Beta2Entry implements AdamEntry = name:"beta2" ":" value:NumberValue;
    EpsilonEntry implements AdamEntry,AdaGradEntry,RmsPropEntry,AdaDeltaEntry = name:"epsilon" ":" value:NumberValue;
    Gamma1Entry implements RmsPropEntry = name:"gamma1" ":" value:NumberValue;
    Gamma2Entry implements RmsPropEntry = name:"gamma2" ":" value:NumberValue;
    CenteredEntry implements RmsPropEntry = name:"centered" ":" value:BooleanValue;
    ClipWeightsEntry implements RmsPropEntry = name:"clip_weights" ":" value:NumberValue;
    RhoEntry implements AdaDeltaEntry = name:"rho" ":" value:NumberValue;
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
96
97

}