Commit e3481fb5 authored by Jean Meurice's avatar Jean Meurice
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/CNNArch2Gluon into sim-dev
parents 57b3cb00 10ae1dc3
Pipeline #495347 failed with stage
in 48 seconds
......@@ -23,7 +23,7 @@
<!-- .. Libraries .................................................. -->
<guava.version>25.1-jre</guava.version>
<junit.version>4.13.1</junit.version>
<logback.version>1.1.2</logback.version>
<logback.version>1.2.0</logback.version>
<jscience.version>4.3.1</jscience.version>
<!-- .. Plugins ....................................................... -->
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch.gluongenerator;
import java.util.HashSet;
......@@ -13,4 +14,4 @@ public class AllAttentionModels {
return models;
}
}
\ No newline at end of file
}
<#-- (c) https://github.com/MontiCore/monticore -->
import mxnet as mx
import logging
import numpy as np
......
<#-- (c) https://github.com/MontiCore/monticore -->
#ifndef CNNMODELLOADER
#define CNNMODELLOADER
......
<#-- (c) https://github.com/MontiCore/monticore -->
import os
import numpy as np
import mxnet as mx
......@@ -98,4 +99,4 @@ class AdamW(mx.optimizer.Optimizer):
adamw_update(w_i, g_i, mean, var, out=w_i, lr=1, wd=wd, eta=lr, **kwargs)
else:
mean, var = s_i[0]
mp_adamw_update(w_i, g_i, mean, var, s_i[1], out=w_i, lr=1, wd=wd, eta=lr, **kwargs)
\ No newline at end of file
mp_adamw_update(w_i, g_i, mean, var, s_i[1], out=w_i, lr=1, wd=wd, eta=lr, **kwargs)
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
<#if mode == "FORWARD_FUNCTION">
<#-- only passtrough method, argmax logic is applied in pythonExecute.ftl and CNNSupervisedTrainer.ftl -->
${element.name} = ${input}
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
<#if mode == "FORWARD_FUNCTION">
${element.name} = F.broadcast_add(${tc.join(element.inputs, ",")})
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
<#if mode == "FORWARD_FUNCTION">
${element.name} = F.broadcast_mul(${tc.join(element.inputs, ", ")})
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
<#if mode == "FORWARD_FUNCTION">
${element.name} = F.batch_dot(${tc.join(element.inputs, ", ")})
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign axis = (element.axis + 1)?c>
<#if mode == "FORWARD_FUNCTION">
${element.name} = F.expand_dims(${element.inputs[0]}, axis=${axis})
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign axis = (element.axis + 1)?c>
<#if mode == "FORWARD_FUNCTION">
${element.name} = F.sum(${element.inputs[0]}, axis=${axis})
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign axis = (element.axis != -1)?then((element.axis + 1)?c, 'None')>
<#assign repeats = element.repeats?c>
<#if mode == "FORWARD_FUNCTION">
${element.name} = F.repeat(${element.inputs[0]}, repeats=${repeats}, axis=${axis})
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
<#if mode == "FORWARD_FUNCTION">
${element.name} = F.reshape(${input}, shape=(0,${tc.join(element.shape, ",")}))
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign axis = (element.axis != -1)?then((element.axis + 1)?c, 'None')>
<#if mode == "FORWARD_FUNCTION">
${element.name} = F.squeeze(${element.inputs[0]}, axis=${axis})
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
<#assign dim1 = (element.axes[0] + 1)?c>
<#assign dim2 = (element.axes[1] + 1)?c>
<#if mode == "FORWARD_FUNCTION">
${element.name} = F.swapaxes(${input}, dim1=${dim1}, dim2=${dim2})
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
gen_inputs = self._net_creator_gen.getInputs()
dis_inputs = self._net_creator_dis.getInputs()
......
<#-- (c) https://github.com/MontiCore/monticore -->
<#setting number_format="computer">
<#assign config = configurations[0]>
......
<#-- (c) https://github.com/MontiCore/monticore -->
<#list tc.architecture.networkInstructions as networkInstruction>
<#if networkInstruction.body.episodicSubNetworks?has_content>
<#if !visitedEpisodicExecuteTrain??>
......@@ -55,4 +56,4 @@
</#list>
<#if visitedEpisodicExecuteTrain??>
pass
</#if>
\ No newline at end of file
</#if>
<#-- (c) https://github.com/MontiCore/monticore -->
labels = [batch.label[i].as_in_context(mx_context[0]) for i in range(${tc.architectureOutputs?size?c})]
<#list tc.architectureInputs as input_name>
${input_name} = batch.data[${input_name?index}].as_in_context(mx_context[0])
......@@ -189,4 +190,4 @@
</#if>
</#list>
</#if>
</#list>
\ No newline at end of file
</#list>
<#-- (c) https://github.com/MontiCore/monticore -->
labels = [gluon.utils.split_and_load(batch.label[i], ctx_list=mx_context, even_split=False) for i in range(${tc.architectureOutputs?size?c})]
<#list tc.architectureInputs as input_name>
......@@ -73,4 +74,4 @@
</#if>
</#list>
</#if>
</#list>
\ No newline at end of file
</#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