diff --git a/src/main/grammars/de/monticore/lang/monticar/CNNTrain.mc4 b/src/main/grammars/de/monticore/lang/monticar/CNNTrain.mc4 index 525531117470d84ea451e7267e6e31b69d903c39..7b10f682fac6767f3e4f9d013721b6a00f8975eb 100644 --- a/src/main/grammars/de/monticore/lang/monticar/CNNTrain.mc4 +++ b/src/main/grammars/de/monticore/lang/monticar/CNNTrain.mc4 @@ -91,6 +91,9 @@ grammar CNNTrain extends de.monticore.lang.monticar.Common2, de.monticore.Number interface SoftmaxCrossEntropyIgnoreIndicesEntry extends Entry; SoftmaxCrossEntropyIgnoreIndicesLoss implements LossValue = name:"softmax_cross_entropy_ignore_indices" ("{" params:SoftmaxCrossEntropyIgnoreIndicesEntry* "}")?; + interface DiceEntry extends Entry; + DiceLoss implements LossValue = name:"dice_loss" ("{" params:DiceEntry* "}")?; + SigmoidBinaryCrossEntropyLoss implements LossValue = name:"sigmoid_binary_cross_entropy" ("{" params:Entry* "}")?; interface HingeEntry extends Entry; @@ -105,13 +108,14 @@ grammar CNNTrain extends de.monticore.lang.monticar.Common2, de.monticore.Number interface KullbackLeiblerEntry extends Entry; KullbackLeiblerLoss implements LossValue = name:"kullback_leibler" ("{" params:KullbackLeiblerEntry* "}")?; - SparseLabelEntry implements CrossEntropyEntry, SoftmaxCrossEntropyEntry, SoftmaxCrossEntropyIgnoreIndicesEntry = name:"sparse_label" ":" value:BooleanValue; - FromLogitsEntry implements SoftmaxCrossEntropyEntry, SoftmaxCrossEntropyIgnoreIndicesEntry, KullbackLeiblerEntry = name:"from_logits" ":" value:BooleanValue; - LossAxisEntry implements CrossEntropyEntry, SoftmaxCrossEntropyEntry, SoftmaxCrossEntropyIgnoreIndicesEntry = name:"loss_axis" ":" value:IntegerValue; - BatchAxisEntry implements CrossEntropyEntry, SoftmaxCrossEntropyEntry, SoftmaxCrossEntropyIgnoreIndicesEntry = name:"batch_axis" ":" value:IntegerValue; + SparseLabelEntry implements CrossEntropyEntry, SoftmaxCrossEntropyEntry, SoftmaxCrossEntropyIgnoreIndicesEntry, DiceEntry = name:"sparse_label" ":" value:BooleanValue; + FromLogitsEntry implements SoftmaxCrossEntropyEntry, SoftmaxCrossEntropyIgnoreIndicesEntry, KullbackLeiblerEntry, DiceEntry = name:"from_logits" ":" value:BooleanValue; + LossAxisEntry implements CrossEntropyEntry, SoftmaxCrossEntropyEntry, SoftmaxCrossEntropyIgnoreIndicesEntry, DiceEntry = name:"loss_axis" ":" value:IntegerValue; + BatchAxisEntry implements CrossEntropyEntry, SoftmaxCrossEntropyEntry, SoftmaxCrossEntropyIgnoreIndicesEntry, DiceEntry = name:"batch_axis" ":" value:IntegerValue; IgnoreIndicesEntry implements SoftmaxCrossEntropyIgnoreIndicesEntry = name:"ignore_indices" ":" value:IntegerValue; MarginEntry implements HingeEntry, SquaredHingeEntry = name:"margin" ":" value:NumberValue; LabelFormatEntry implements LogisticEntry = name:"label_format" ":" value:StringValue; + //DiceWeight implements DiceEntry = name: "dice_weight" ":" value:DoubleVectorValue; interface OptimizerValue extends ConfigValue; interface SGDEntry extends OptimizerParamEntry; diff --git a/src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/ParameterAlgorithmMapping.java b/src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/ParameterAlgorithmMapping.java index bdda3f339a3eb40249f57b39b6d67adc104cc402..1bf00438c9aa1650c108bd5190c826f358ef40eb 100644 --- a/src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/ParameterAlgorithmMapping.java +++ b/src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/ParameterAlgorithmMapping.java @@ -51,6 +51,7 @@ class ParameterAlgorithmMapping { ASTBatchAxisEntry.class, ASTFromLogitsEntry.class, ASTIgnoreIndicesEntry.class, + //ASTDiceWeightEntry.class, ASTMarginEntry.class, ASTLabelFormatEntry.class, ASTRhoEntry.class, diff --git a/src/test/resources/valid_tests/FullConfig3.cnnt b/src/test/resources/valid_tests/FullConfig3.cnnt new file mode 100644 index 0000000000000000000000000000000000000000..ad33493069ba3b860d924ad1ba8c37983373fc82 --- /dev/null +++ b/src/test/resources/valid_tests/FullConfig3.cnnt @@ -0,0 +1,30 @@ +/* (c) https://github.com/MontiCore/monticore */ +configuration FullConfig{ + num_epoch : 5 + batch_size : 100 + load_checkpoint : true + eval_metric : mse + loss: dice_loss{ + sparse_label: true + from_logits: true + loss_axis : -1 + batch_axis: 0 + } + context : gpu + normalize : true + optimizer : rmsprop{ + learning_rate : 0.001 + learning_rate_minimum : 0.00001 + weight_decay : 0.01 + learning_rate_decay : 0.9 + learning_rate_policy : step + step_size : 1000 + rescale_grad : 1.1 + clip_gradient : 10 + gamma1 : 0.9 + gamma2 : 0.9 + epsilon : 0.000001 + centered : true + clip_weights : 10 + } +}