Commit 7d63a097 authored by Bernhard Rumpe's avatar Bernhard Rumpe
Browse files

BR-sy

parent b2564edd
Pipeline #477182 failed with stages
in 7 minutes and 29 seconds
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch.gluongenerator; package de.monticore.lang.monticar.cnnarch.gluongenerator;
import java.util.HashSet; import java.util.HashSet;
...@@ -13,4 +14,4 @@ public class AllAttentionModels { ...@@ -13,4 +14,4 @@ public class AllAttentionModels {
return models; return models;
} }
} }
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
import mxnet as mx import mxnet as mx
import logging import logging
import numpy as np import numpy as np
......
<#-- (c) https://github.com/MontiCore/monticore -->
#ifndef CNNMODELLOADER #ifndef CNNMODELLOADER
#define CNNMODELLOADER #define CNNMODELLOADER
......
<#-- (c) https://github.com/MontiCore/monticore -->
import os import os
import numpy as np import numpy as np
import mxnet as mx import mxnet as mx
...@@ -98,4 +99,4 @@ class AdamW(mx.optimizer.Optimizer): ...@@ -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) adamw_update(w_i, g_i, mean, var, out=w_i, lr=1, wd=wd, eta=lr, **kwargs)
else: else:
mean, var = s_i[0] 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) 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
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]> <#assign input = element.inputs[0]>
<#if mode == "FORWARD_FUNCTION"> <#if mode == "FORWARD_FUNCTION">
<#-- only passtrough method, argmax logic is applied in pythonExecute.ftl and CNNSupervisedTrainer.ftl --> <#-- only passtrough method, argmax logic is applied in pythonExecute.ftl and CNNSupervisedTrainer.ftl -->
${element.name} = ${input} ${element.name} = ${input}
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
<#if mode == "FORWARD_FUNCTION"> <#if mode == "FORWARD_FUNCTION">
${element.name} = F.broadcast_add(${tc.join(element.inputs, ",")}) ${element.name} = F.broadcast_add(${tc.join(element.inputs, ",")})
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
<#if mode == "FORWARD_FUNCTION"> <#if mode == "FORWARD_FUNCTION">
${element.name} = F.broadcast_mul(${tc.join(element.inputs, ", ")}) ${element.name} = F.broadcast_mul(${tc.join(element.inputs, ", ")})
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
<#if mode == "FORWARD_FUNCTION"> <#if mode == "FORWARD_FUNCTION">
${element.name} = F.batch_dot(${tc.join(element.inputs, ", ")}) ${element.name} = F.batch_dot(${tc.join(element.inputs, ", ")})
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign axis = (element.axis + 1)?c> <#assign axis = (element.axis + 1)?c>
<#if mode == "FORWARD_FUNCTION"> <#if mode == "FORWARD_FUNCTION">
${element.name} = F.expand_dims(${element.inputs[0]}, axis=${axis}) ${element.name} = F.expand_dims(${element.inputs[0]}, axis=${axis})
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign axis = (element.axis + 1)?c> <#assign axis = (element.axis + 1)?c>
<#if mode == "FORWARD_FUNCTION"> <#if mode == "FORWARD_FUNCTION">
${element.name} = F.sum(${element.inputs[0]}, axis=${axis}) ${element.name} = F.sum(${element.inputs[0]}, axis=${axis})
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign axis = (element.axis != -1)?then((element.axis + 1)?c, 'None')> <#assign axis = (element.axis != -1)?then((element.axis + 1)?c, 'None')>
<#assign repeats = element.repeats?c> <#assign repeats = element.repeats?c>
<#if mode == "FORWARD_FUNCTION"> <#if mode == "FORWARD_FUNCTION">
${element.name} = F.repeat(${element.inputs[0]}, repeats=${repeats}, axis=${axis}) ${element.name} = F.repeat(${element.inputs[0]}, repeats=${repeats}, axis=${axis})
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]> <#assign input = element.inputs[0]>
<#if mode == "FORWARD_FUNCTION"> <#if mode == "FORWARD_FUNCTION">
${element.name} = F.reshape(${input}, shape=(0,${tc.join(element.shape, ",")})) ${element.name} = F.reshape(${input}, shape=(0,${tc.join(element.shape, ",")}))
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign axis = (element.axis != -1)?then((element.axis + 1)?c, 'None')> <#assign axis = (element.axis != -1)?then((element.axis + 1)?c, 'None')>
<#if mode == "FORWARD_FUNCTION"> <#if mode == "FORWARD_FUNCTION">
${element.name} = F.squeeze(${element.inputs[0]}, axis=${axis}) ${element.name} = F.squeeze(${element.inputs[0]}, axis=${axis})
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]> <#assign input = element.inputs[0]>
<#assign dim1 = (element.axes[0] + 1)?c> <#assign dim1 = (element.axes[0] + 1)?c>
<#assign dim2 = (element.axes[1] + 1)?c> <#assign dim2 = (element.axes[1] + 1)?c>
<#if mode == "FORWARD_FUNCTION"> <#if mode == "FORWARD_FUNCTION">
${element.name} = F.swapaxes(${input}, dim1=${dim1}, dim2=${dim2}) ${element.name} = F.swapaxes(${input}, dim1=${dim1}, dim2=${dim2})
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
gen_inputs = self._net_creator_gen.getInputs() gen_inputs = self._net_creator_gen.getInputs()
dis_inputs = self._net_creator_dis.getInputs() dis_inputs = self._net_creator_dis.getInputs()
......
<#-- (c) https://github.com/MontiCore/monticore -->
<#setting number_format="computer"> <#setting number_format="computer">
<#assign config = configurations[0]> <#assign config = configurations[0]>
......
<#-- (c) https://github.com/MontiCore/monticore -->
<#list tc.architecture.networkInstructions as networkInstruction> <#list tc.architecture.networkInstructions as networkInstruction>
<#if networkInstruction.body.episodicSubNetworks?has_content> <#if networkInstruction.body.episodicSubNetworks?has_content>
<#if !visitedEpisodicExecuteTrain??> <#if !visitedEpisodicExecuteTrain??>
...@@ -55,4 +56,4 @@ ...@@ -55,4 +56,4 @@
</#list> </#list>
<#if visitedEpisodicExecuteTrain??> <#if visitedEpisodicExecuteTrain??>
pass pass
</#if> </#if>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
labels = [batch.label[i].as_in_context(mx_context[0]) for i in range(${tc.architectureOutputs?size?c})] labels = [batch.label[i].as_in_context(mx_context[0]) for i in range(${tc.architectureOutputs?size?c})]
<#list tc.architectureInputs as input_name> <#list tc.architectureInputs as input_name>
${input_name} = batch.data[${input_name?index}].as_in_context(mx_context[0]) ${input_name} = batch.data[${input_name?index}].as_in_context(mx_context[0])
...@@ -189,4 +190,4 @@ ...@@ -189,4 +190,4 @@
</#if> </#if>
</#list> </#list>
</#if> </#if>
</#list> </#list>
\ No newline at end of file
<#-- (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})] 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> <#list tc.architectureInputs as input_name>
...@@ -73,4 +74,4 @@ ...@@ -73,4 +74,4 @@
</#if> </#if>
</#list> </#list>
</#if> </#if>
</#list> </#list>
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
if save_attention_image == "True": if save_attention_image == "True":
if not eval_train: if not eval_train:
import matplotlib import matplotlib
...@@ -38,4 +39,4 @@ ...@@ -38,4 +39,4 @@
if not os.path.exists(target_dir): if not os.path.exists(target_dir):
os.makedirs(target_dir) os.makedirs(target_dir)
plt.savefig(target_dir + '/attention_test.png') plt.savefig(target_dir + '/attention_test.png')
plt.close() plt.close()
\ 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