Commit 2d98cca1 authored by Sebastian Nickels's avatar Sebastian Nickels

Added support for eval metric parameters

parent dbba18a6
Pipeline #196733 failed with stages
in 1 minute and 15 seconds
package de.monticore.lang.monticar.cnnarch.generator;
import de.monticore.lang.monticar.cnntrain._symboltable.*;
import static de.monticore.lang.monticar.cnntrain.helper.ConfigEntryNameConstants.*;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -60,11 +61,8 @@ public class ConfigurationData {
return getConfiguration().getEntry("context").getValue().toString();
}
public String getEvalMetric() {
if (!getConfiguration().getEntryMap().containsKey("eval_metric")) {
return null;
}
return getConfiguration().getEntry("eval_metric").getValue().toString();
public Map<String, Object> getEvalMetric() {
return getMultiParamEntry(EVAL_METRIC, "name");
}
public String getLossName() {
......@@ -122,4 +120,33 @@ public class ConfigurationData {
}
return mapToStrings;
}
protected Map<String, Object> getMultiParamEntry(final String key, final String valueName) {
if (!configurationContainsKey(key)) {
return null;
}
Map<String, Object> resultView = new HashMap<>();
ValueSymbol value = this.getConfiguration().getEntryMap().get(key).getValue();
if (value instanceof MultiParamValueSymbol) {
MultiParamValueSymbol multiParamValue = (MultiParamValueSymbol) value;
resultView.put(valueName, multiParamValue.getValue());
resultView.putAll(multiParamValue.getParameters());
}
else {
resultView.put(valueName, value.getValue());
}
return resultView;
}
protected Boolean configurationContainsKey(final String key) {
return this.getConfiguration().getEntryMap().containsKey(key);
}
protected Object retrieveConfigurationEntryValueByKey(final String key) {
return this.getConfiguration().getEntry(key).getValue().getValue();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment