Commit fa7fd8ee authored by Julian Treiber's avatar Julian Treiber

added weightsPath

parent 8798cd10
Pipeline #248018 failed with stages
......@@ -70,10 +70,14 @@ public abstract class CNNArchGenerator {
ArchitectureSymbol architectureSymbol = symbolCompiler.compileArchitectureSymbol(scope, rootModelName);
try{
String confPath = getModelsDirPath() + "/data_paths.txt";
DataPathConfigParser newParserConfig = new DataPathConfigParser(confPath);
String dataPath = newParserConfig.getDataPath(rootModelName);
String dataConfPath = getModelsDirPath() + "/data_paths.txt";
DataPathConfigParser dataParserConfig = new DataPathConfigParser(dataConfPath);
String dataPath = dataParserConfig.getDataPath(rootModelName);
architectureSymbol.setDataPath(dataPath);
String weightsConfPath = getModelsDirPath() + "/weights_paths.txt";
WeightsPathConfigParser weightsParserConfig = new WeightsPathConfigParser(weightsConfPath);
String weightsPath = weightsParserConfig.getWeightsPath(rootModelName);
architectureSymbol.setWeightsPath(weightsPath);
architectureSymbol.setComponentName(rootModelName);
generateFiles(architectureSymbol);
} catch (IOException e){
......
......@@ -10,7 +10,7 @@ import java.io.Writer;
import java.util.*;
public abstract class CNNArchTemplateController {
public static final String FTL_FILE_ENDING = ".ftl";
public static final String TEMPLATE_ELEMENTS_DIR_PATH = "elements/";
public static final String TEMPLATE_CONTROLLER_KEY = "tc";
......@@ -116,7 +116,11 @@ public abstract class CNNArchTemplateController {
public String getDataPath(){
return getArchitecture().getDataPath();
}
public String getWeightsPath(){
return getArchitecture().getWeightsPath();
}
public List<String> getLayerInputs(ArchitectureElementSymbol layer){
List<String> inputNames = new ArrayList<>();
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch.generator;
import de.se_rwth.commons.logging.Log;
import java.io.*;
import java.util.Properties;
public class WeightsPathConfigParser{
private String configTargetPath;
private Properties properties;
public WeightsPathConfigParser(String configPath) {
setConfigPath(configPath);
properties = new Properties();
try
{
properties.load(new FileInputStream(configTargetPath));
} catch(IOException e)
{
Log.error("Config file " + configPath + " could not be found");
}
}
public String getConfigPath() {
if (configTargetPath.charAt(configTargetPath.length() - 1) != '/') {
this.configTargetPath = configTargetPath + "/";
}
return configTargetPath;
}
public void setConfigPath(String configTargetPath){
this.configTargetPath = configTargetPath;
}
public String getWeightsPath(String modelName) {
String path = properties.getProperty(modelName);
if(path == null) {
Log.warn("Weights path config file did not specify a path for component '" + modelName + "'");
return path;
}
return path;
}
}
ComponentName /path/to/training/weights
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