Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: LFS, Container Registry, Job Artifacs, Uploads (Wiki, Bilder, Projekt-Exporte). Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit 79d825a6 authored by Kirhan, Cihad's avatar Kirhan, Cihad
Browse files

ConfLang integration

parent f9ccf64e
Pipeline #444650 failed with stage
in 31 seconds
......@@ -2,22 +2,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<!-- == PROJECT COORDINATES ============================================= -->
<!-- == PROJECT COORDINATES ============================================= -->
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnnarch-mxnet-generator</artifactId>
<version>0.4.5</version>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnnarch-mxnet-generator</artifactId>
<version>0.4.5</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
<!-- == PROJECT DEPENDENCIES ============================================= -->
<properties>
<properties>
<!-- .. SE-Libraries .................................................. -->
<CNNArch2X.version>0.4.6-SNAPSHOT</CNNArch2X.version>
<conflang.version>0.9.0-SNAPSHOT</conflang.version>
<!-- .. SE-Libraries .................................................. -->
<CNNArch2X.version>0.4.5</CNNArch2X.version>
<!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version>
<junit.version>4.12</junit.version>
......@@ -31,16 +32,16 @@
<shade.plugin>2.4.3</shade.plugin>
<jacoco.plugin>0.8.1</jacoco.plugin>
<!-- Classifiers -->
<grammars.classifier>grammars</grammars.classifier>
<cli.classifier>cli</cli.classifier>
<!-- Classifiers -->
<grammars.classifier>grammars</grammars.classifier>
<cli.classifier>cli</cli.classifier>
<!-- .. Misc .......................................................... -->
<java.version>1.8</java.version>
<!-- .. Misc .......................................................... -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
......@@ -57,13 +58,17 @@
</dependency>
<!-- MontiCore Dependencies -->
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnnarch-generator</artifactId>
<artifactId>cnnarch-generator-conflang</artifactId>
<version>${CNNArch2X.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang</groupId>
<artifactId>conflang</artifactId>
<version>${conflang.version}</version>
</dependency>
<!-- .. Test Libraries ............................................... -->
<dependency>
......@@ -92,97 +97,98 @@
</dependency>
</dependencies>
<!-- == PROJECT BUILD SETTINGS =========================================== -->
<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<!-- Test coverage -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.plugin}</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Other Configuration -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler.plugin}</version>
<configuration>
<useIncrementalCompilation>true</useIncrementalCompilation>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>de.monticore.lang.monticar.cnnarch.mxnetgenerator.CNNArch2MxNetCli</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
<!-- Source Jar Configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${source.plugin}</version>
<executions>
<execution>
<id>create source jar</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
<configuration>
<excludeResources>false</excludeResources>
<includes>
<include>**/*.java</include>
<include>**/*.ftl</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- == PROJECT BUILD SETTINGS =========================================== -->
<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<!-- Test coverage -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.plugin}</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Other Configuration -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler.plugin}</version>
<configuration>
<useIncrementalCompilation>true</useIncrementalCompilation>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>de.monticore.lang.monticar.cnnarch.mxnetgenerator.CNNArch2MxNetCli
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
<!-- Source Jar Configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${source.plugin}</version>
<executions>
<execution>
<id>create source jar</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
<configuration>
<excludeResources>false</excludeResources>
<includes>
<include>**/*.java</include>
<include>**/*.ftl</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
......@@ -207,9 +213,9 @@
<!-- aggregated reports for multi-module projects -->
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugins>
</build>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch.mxnetgenerator;
import com.google.common.collect.Lists;
import conflang._symboltable.ConfLangConfigurationSymbol;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.monticar.cnnarch.generator.CNNTrainGenerator;
import de.monticore.lang.monticar.cnnarch.generator.ConfigurationData;
......@@ -49,4 +51,18 @@ public class CNNTrain2MxNet extends CNNTrainGenerator {
fileContents.add(temp);
return fileContents;
}
}
@Override
public List<FileContent> generateFileContents(ConfLangConfigurationSymbol configuration, Map<String, Object> architectureAdapterMap) {
TemplateConfiguration templateConfiguration = new MxNetTemplateConfiguration();
MxNetConfigurationDataConfLang configData = new MxNetConfigurationDataConfLang(configuration, getInstanceName());
List<MxNetConfigurationDataConfLang> configDataList = Lists.newArrayList(configData);
Map<String, Object> ftlContext = Collections.singletonMap("configurations", configDataList);
String templateContent = templateConfiguration.processTemplate(ftlContext, "CNNTrainerConfLang.ftl");
List<FileContent> fileContents = new ArrayList<>();
FileContent temp = new FileContent(templateContent, "CNNTrainerConfLang_" + getInstanceName() + ".py");
fileContents.add(temp);
return fileContents;
}
}
\ No newline at end of file
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch.mxnetgenerator;
public class TrainingParameterConstants {
public static final String BATCH_SIZE = "batch_size";
public static final String NUM_EPOCH = "num_epoch";
public static final String LOAD_CHECKPOINT = "load_checkpoint";
public static final String CHECKPOINT_PERIOD = "checkpoint_period";
public static final String LOG_PERIOD = "log_period";
public static final String LOAD_PRETRAINED = "load_pretrained";
public static final String NORMALIZE = "normalize";
public static final String CONTEXT = "context";
public static final String SHUFFLE_DATA = "shuffle_data";
public static final String CLIP_GLOBAL_GRAD_NORM = "clip_global_grad_norm";
public static final String USE_TEACHER_FORCING = "use_teacher_forcing";
public static final String SAVE_ATTENTION_IMAGE = "save_attention_image";
public static final String EVAL_TRAIN = "eval_train";
public static final String OPTIMIZER = "optimizer";
public static final String ACTOR_OPTIMIZER = "actor_optimizer";
public static final String CRITIC_OPTIMIZER = "critic_optimizer";
// Refinforcement
public static final String REWARD_FUNCTION = "reward_function";
public static final String LEARNING_METHOD = "learning_method";
public static final String EVAL_METRIC = "eval_metric";
public static final String NUM_EPISODES = "num_episodes";
public static final String DISCOUNT_FACTOR = "discount_factor";
public static final String NUM_MAX_STEPS = "num_max_steps";
public static final String TARGET_SCORE = "target_score";
public static final String TRAINING_INTERVAL = "training_interval";
public static final String USE_FIX_TARGET_NETWORK = "use_fix_target_network";
public static final String TARGET_NETWORK_UPDATE_INTERVAL = "target_network_update_interval";
public static final String SNAPSHOT_INTERVAL = "snapshot_interval";
public static final String AGENT_NAME = "agent_name";
public static final String USE_DOUBLE_DQN = "use_double_dqn";
public static final String LOSS = "loss";
public static final String RL_ALGORITHM = "rl_algorithm";
public static final String REPLAY_MEMORY = "replay_memory";
public static final String ENVIRONMENT = "environment";
public static final String START_TRAINING_AT = "start_training_at";
public static final String SOFT_TARGET_UPDATE_RATE = "soft_target_update_rate";
public static final String EVALUATION_SAMPLES = "evaluation_samples";
public static final String POLICY_NOISE = "policy_noise";
public static final String NOISE_CLIP = "noise_clip";
public static final String POLICY_DELAY = "policy_delay";
public static final String ENVIRONMENT_REWARD_TOPIC = "reward_topic";
public static final String ENVIRONMENT_ROS = "ros_interface";
public static final String ENVIRONMENT_GYM = "gym";
public static final String STRATEGY = "strategy";
public static final String STRATEGY_OU = "ornstein_uhlenbeck";
public static final String STRATEGY_OU_MU = "mu";
public static final String STRATEGY_OU_THETA = "theta";
public static final String STRATEGY_OU_SIGMA = "sigma";
public static final String STRATEGY_GAUSSIAN = "gaussian";
public static final String STRATEGY_EPSGREEDY = "epsgreedy";
public static final String STRATEGY_EPSDECAY = "epsdecay";
public static final String CRITIC = "critic";
public static final String DISCRIMINATOR_NAME = "discriminator_name";
public static final String QNETWORK_NAME = "qnet_name";
public static final String PREPROCESSING_NAME = "preprocessing_name";
public static final String NOISE_DISTRIBUTION = "noise_distribution";
public static final String CONSTRAINT_DISTRIBUTION = "constraint_distributions";
public static final String CONSTRAINT_LOSS = "constraint_losses";
public static final String DISCRIMINATOR_OPTIMIZER = "discriminator_optimizer";
public static final String K_VALUE = "k_value";
public static final String GENERATOR_LOSS = "generator_loss";
public static final String GENERATOR_TARGET_NAME = "generator_target_name";
public static final String NOISE_INPUT = "noise_input";
public static final String GENERATOR_LOSS_WEIGHT = "generator_loss_weight";
public static final String DISCRIMINATOR_LOSS_WEIGHT = "discriminator_loss_weight";
public static final String PRINT_IMAGES = "print_images";
}
<#-- (c) https://github.com/MontiCore/monticore -->
import logging
import mxnet as mx
<#list configurations as config>
import CNNCreator_${config.instanceName}
</#list>
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
handler = logging.FileHandler("train.log", "w", encoding=None, delay="true")
logger.addHandler(handler)
<#list configurations as config>
${config.instanceName} = CNNCreator_${config.instanceName}.CNNCreator_${config.instanceName}()
${config.instanceName}.train(
<#if (config.batchSize)??>
batch_size=${config.batchSize},
</#if>
<#if (config.numEpoch)??>
num_epoch=${config.numEpoch},
</#if>
<#if (config.loadCheckpoint)??>
load_checkpoint=${config.loadCheckpoint?string("True","False")},
</#if>
<#if (config.context)??>
context='${config.context}',
</#if>
<#if (config.normalize)??>
normalize=${config.normalize?string("True","False")},
</#if>
<#if (config.evalMetric)??>
eval_metric='${config.evalMetric.name}',
</#if>
<#if (config.loss)??>
loss='${config.lossName}',
<#if (config.lossParams)??>
loss_params={
<#list config.lossParameters?keys as param>
'${param}': ${config.lossParameters[param]}<#sep>,
</#list>
},
</#if>
</#if>
<#if (config.optimizer)??>
optimizer='${config.optimizerName}',
optimizer_params={
<#list config.optimizerParameters?keys as param>
'${param}': ${config.optimizerParameters[param]}<#sep>,
</#list>
}
</#if>
)
</#list>
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