Aufgrund einer Wartung wird GitLab am 19.10. zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 19.10. between 8:00 and 9:00 am.

Commit 46333043 authored by Nicola Gatto's avatar Nicola Gatto
Browse files

Checks for trained network inputs and outputs

parent 3d15a4de
......@@ -48,11 +48,17 @@ public class CNNTrainCocos {
createChecker().checkAll(node);
}
public static void checkTrainedArchitectureCoCos(final ConfigurationSymbol configurationSymbol) {
CNNTrainConfigurationSymbolChecker checker = new CNNTrainConfigurationSymbolChecker()
.addCoCo(new CheckTrainedRlNetworkHasExactlyOneInput())
.addCoCo(new CheckTrainedRlNetworkHasExactlyOneOutput());
checker.checkAll(configurationSymbol);
}
public static void checkCriticCocos(final ConfigurationSymbol configurationSymbol) {
CNNTrainConfigurationSymbolChecker checker = new CNNTrainConfigurationSymbolChecker()
.addCoCo(new CheckCriticNetworkHasExactlyAOneDimensionalOutput())
.addCoCo(new CheckCriticNetworkInputs());
int findings = Log.getFindings().size();
checker.checkAll(configurationSymbol);
}
}
\ No newline at end of file
package de.monticore.lang.monticar.cnntrain._cocos;
import de.monticore.lang.monticar.cnntrain._symboltable.ConfigurationSymbol;
import de.monticore.lang.monticar.cnntrain._symboltable.RLAlgorithm;
import de.monticore.lang.monticar.cnntrain.helper.ErrorCodes;
import de.se_rwth.commons.logging.Log;
/**
*
*/
public class CheckTrainedRlNetworkHasExactlyOneInput implements CNNTrainConfigurationSymbolCoCo {
@Override
public void check(ConfigurationSymbol configurationSymbol) {
if (configurationSymbol.isReinforcementLearningMethod()
&& configurationSymbol.getTrainedArchitecture().isPresent()) {
final int numberOfInputs = configurationSymbol.getTrainedArchitecture().get().getInputs().size();
if (numberOfInputs != 1) {
final String networkName
= configurationSymbol.getEntry("rl_algorithm").getValue().getValue()
.equals(RLAlgorithm.DQN) ? "Q-Network" : "Actor-Network";
Log.error("x0" + ErrorCodes.TRAINED_ARCHITECTURE_ERROR
+ networkName + " " +configurationSymbol.getTrainedArchitecture().get().getName()
+" has " + numberOfInputs + " inputs but 1 is only allowed.", configurationSymbol.getSourcePosition());
}
}
}
}
\ No newline at end of file
package de.monticore.lang.monticar.cnntrain._cocos;
import de.monticore.lang.monticar.cnntrain._symboltable.ConfigurationSymbol;
import de.monticore.lang.monticar.cnntrain._symboltable.RLAlgorithm;
import de.monticore.lang.monticar.cnntrain.helper.ErrorCodes;
import de.se_rwth.commons.logging.Log;
/**
*
*/
public class CheckTrainedRlNetworkHasExactlyOneOutput implements CNNTrainConfigurationSymbolCoCo {
@Override
public void check(final ConfigurationSymbol configurationSymbol) {
if (configurationSymbol.isReinforcementLearningMethod()
&& configurationSymbol.getTrainedArchitecture().isPresent()) {
final int numberOfOutputs = configurationSymbol.getTrainedArchitecture().get().getOutputs().size();
if (numberOfOutputs != 1) {
final String networkName
= configurationSymbol.getEntry("rl_algorithm").getValue().getValue()
.equals(RLAlgorithm.DQN) ? "Q-Network" : "Actor-Network";
Log.error("x0" + ErrorCodes.TRAINED_ARCHITECTURE_ERROR
+ networkName + " " +configurationSymbol.getTrainedArchitecture().get().getName()
+" has " + numberOfOutputs + " outputs but 1 is only allowed.", configurationSymbol.getSourcePosition());
}
}
}
}
\ No newline at end of file
......@@ -33,4 +33,5 @@ public class ErrorCodes {
public static final String CONTRADICTING_PARAMETERS = "xC8858";
public static final String CRITIC_NETWORK_ERROR = "xC7100";
public static final String MISSING_TRAINED_ARCHITECTURE = "xC7101";
public static final String TRAINED_ARCHITECTURE_ERROR = "xC7102";
}
\ No newline at end of file
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