Commit 9f4a8018 authored by Julian Dierkes's avatar Julian Dierkes
Browse files

Merge branch 'develop' of...

Merge branch 'develop' of git.rwth-aachen.de:monticore/EmbeddedMontiArc/languages/CNNArchLang into develop
parents 52667121 3ce668ef
Pipeline #223025 passed with stages
in 19 minutes and 56 seconds
# #
# #
# ****************************************************************************** # (c) https://github.com/MontiCore/monticore
# MontiCAR Modeling Family, www.se-rwth.de
# Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
# All rights reserved.
# #
# This project is free software; you can redistribute it and/or # The license generally applicable for this project
# modify it under the terms of the GNU Lesser General Public # can be found under https://github.com/MontiCore/monticore.
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this project. If not, see <http://www.gnu.org/licenses/>.
# *******************************************************************************
# #
# (c) https://github.com/MontiCore/monticore
# Java Maven CircleCI 2.0 configuration file # Java Maven CircleCI 2.0 configuration file
# #
# Check https://circleci.com/docs/2.0/language-java/ for more details # Check https://circleci.com/docs/2.0/language-java/ for more details
......
# #
# #
# ****************************************************************************** # (c) https://github.com/MontiCore/monticore
# MontiCAR Modeling Family, www.se-rwth.de
# Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
# All rights reserved.
# #
# This project is free software; you can redistribute it and/or # The license generally applicable for this project
# modify it under the terms of the GNU Lesser General Public # can be found under https://github.com/MontiCore/monticore.
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# #
# You should have received a copy of the GNU Lesser General Public
# License along with this project. If not, see <http://www.gnu.org/licenses/>. # (c) https://github.com/MontiCore/monticore
# *******************************************************************************
# #
stages: stages:
#- test
- windows - windows
- linux - linux
#include:
# template: License-Management.gitlab-ci.yml
#license_management:
# variables:
# MAVEN_CLI_OPTS: --settings=settings.xml
masterJobLinux: masterJobLinux:
stage: linux stage: linux
image: maven:3-jdk-8 image: maven:3-jdk-8
script: script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean deploy --settings settings.xml - mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean deploy --settings settings.xml
- mvn package sonar:sonar -s settings.xml - mvn package sonar:sonar -s settings.xml
except:
changes:
- README.md
- .gitignore
- .gitlab-ci.yml
only: only:
- master - master
...@@ -37,7 +41,11 @@ masterJobWindows: ...@@ -37,7 +41,11 @@ masterJobWindows:
script: script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml - mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
tags: tags:
- Windows10_OS - Windows10
except:
changes:
- README.md
- .gitignore
BranchJobLinux: BranchJobLinux:
stage: linux stage: linux
...@@ -46,3 +54,7 @@ BranchJobLinux: ...@@ -46,3 +54,7 @@ BranchJobLinux:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml - mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
except: except:
- master - master
except:
changes:
- README.md
- .gitignore
# (c) https://github.com/MontiCore/monticore
script: script:
- git checkout ${TRAVIS_BRANCH} - git checkout ${TRAVIS_BRANCH}
- mvn clean install cobertura:cobertura org.eluder.coveralls:coveralls-maven-plugin:report --settings "settings.xml" - mvn clean install cobertura:cobertura org.eluder.coveralls:coveralls-maven-plugin:report --settings "settings.xml"
......
<!-- (c) https://github.com/MontiCore/monticore -->
![pipeline](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/languages/CNNArchLang/badges/master/build.svg) ![pipeline](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/languages/CNNArchLang/badges/master/build.svg)
![coverage](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/languages/CNNArchLang/badges/master/coverage.svg) ![coverage](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/languages/CNNArchLang/badges/master/coverage.svg)
# CNNArch # CNNArch
**!!Attention:
For all layers with padding: For the gluon backend currently only the default value is working ("same"). As there is and was the same
custom calculations done there is no behaviorial change to previous versions. See the following issue:
https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/cnnarch2x/issues/2
!!**
## Introduction ## Introduction
CNNArch is a descriptive language to model architectures of feedforward neural networks with a special focus on convolutional neural networks. CNNArch is a descriptive language to model architectures of feedforward neural networks with a special focus on convolutional neural networks.
It is being developed for use in the MontiCar language family, along with CNNTrain, which configures the training of the network, and EmbeddedMontiArcDL, which integrates CNNArch into EmbeddedMontiArc. It is being developed for use in the MontiCar language family, along with CNNTrain, which configures the training of the network, and EmbeddedMontiArcDL, which integrates CNNArch into EmbeddedMontiArc.
...@@ -143,6 +151,13 @@ The following is a example of multiple layer declarations. ...@@ -143,6 +151,13 @@ The following is a example of multiple layer declarations.
The constructed layer `resLayer` in this example corresponds to a building block of a Residual Network. The constructed layer `resLayer` in this example corresponds to a building block of a Residual Network.
The `?` argument is a special argument which is explained in the next section. The `?` argument is a special argument which is explained in the next section.
## Introducing new Predefined Layers
In order to introduce a new predefined layer, the following steps are necessary:
* A new class for the respective layer has to be introduced in the "predefined" folder of CNNArch.
* The name of the layer and its arguments (if they are new) have to be added to the AllPredefinedLayers class in the "predefined" folder. The "create()" method for the new layer must be called in AllPredefinedLayers.
* If the layer uses newly introduced arguments, a get() method for these arguments must be implemented in the CNNArch2X project, in the class "ArchitectureElementData".
* Finally, the class must be implemented for the respective backend, e.g. by adding a corresponding .ftl file to the "elements" folder in CNNArch2Gluon, or similarly for other backends.
## Structural Arguments ## Structural Arguments
Structural arguments are special arguments which can be set for each layer and which do not correspond to a layer parameter. Structural arguments are special arguments which can be set for each layer and which do not correspond to a layer parameter.
The three structural arguments are "?", "->" and "|". The conditional argument "?" is a boolean. The three structural arguments are "?", "->" and "|". The conditional argument "?" is a boolean.
...@@ -403,3 +418,77 @@ All predefined methods start with a capital letter and all constructed methods h ...@@ -403,3 +418,77 @@ All predefined methods start with a capital letter and all constructed methods h
* **size** (integer > 0, optional): The OneHot-vector's size. Can be omitted to automatically use the output size of the architecture. * **size** (integer > 0, optional): The OneHot-vector's size. Can be omitted to automatically use the output size of the architecture.
* **ArgMax()**
Computes the index of the maximal value of its input vector. Useful for recurrent networks, when the output of a timestep should be used as integer input for the next timestep.
* **BeamSearch(max_length, width)**
Must be used together with a recurrent network. Uses Beamsearch as search algorithm over the timesteps of the RNN.
* **max_length** (integer > 0, required): The maximum number of timesteps to run the RNN, and thus the maximum length of the generated sequence.
* **width** (integer > 0, required): The number of candidates to consider each in timestep. Sometimes called k.
* **BroadcastAdd()**
Takes multiple tensors as input, and broadcasts them to the same shape (Copies values along one axis until it has the size of the largest axis along all inputs). Then performs elementswise addition.
* **BroadcastMultiply()**
Takes multiple tensors as input, and broadcasts them to the same shape (Copies values along one axis until it has the size of the largest axis along all inputs). Then performs elementswise multiplication.
* **Dot()**
Performs the dot product (matrix multiplication) for two input matrices.
* **ExpandDims(axis)**
Creates a new, empty axis for a given input tensor.
* **axis** (0 <= integer <= 1, required): The axis to expand.
* **GreedySearch(max_length)**
Must be used together with a recurrent network. Uses Greedysearch as search algorithm over the timesteps of the RNN, so that only the best output for each timestep is considered.
* **max_length** (integer > 0, required): The maximum number of timesteps to run the RNN, and thus the maximum length of the generated sequence.
* **ReduceSum(axis)**
Sums all values along a given axis, and reduces the dimension of the axis afterwards, making a scalar out of a one-entry vector etc.
* **axis** (0 <= integer <= 1, optional, default=-1): The axis to sum over. Uses the last axis (-1) by default.
* **Repeat(n, axis)**
Copies the entries of an axis n times in the same axis.
* **n** (integer > 0, required): How often to copy the entries of the given axis
* **axis** (-1 <= integer <= 2, optional, default=-1): The axis to use for copying. Uses the last axis (-1) by default.
* **Reshape(shape)**
Transforms the input tensor into a different shape, while keeping the number of total entries in the tensor.
* **shape** (integer tuple, required): New shape of the tensor.
* **UpConvolution(kernel, channels, stride=(1,1), no_bias=false, padding="same")**
Creates a up convolutional layer (also known as transposed convolution ). Is currently only supported in the tesnsorflow backend.
* **kernel** (integer tuple > 0, required): convolution kernel size: (height, width).
* **channels** (integer > 0, required): number of up convolution filters and number of output channels.
* **stride** (integer tuple > 0, optional, default=(1,1)): up convolution stride: (height, width).
* **padding** ({"valid", "same", "no_loss"}, optional, default="same"): One of "valid", "same" or "no_loss". "valid" means no padding. "same" results in padding the input such that the output has the same length as the original input divided by the stride (rounded up). "no_loss" results in minimal padding such that each input is used by at least one filter (identical to "valid" if *stride* equals 1).
* **no_bias** (boolean, optional, default=false): Whether to disable the bias parameter.
<!-- <!--
****************************************************************************** (c) https://github.com/MontiCore/monticore
MontiCAR Modeling Family, www.se-rwth.de
Copyright (c) 2017, Software Engineering Group at RWTH Aachen, The license generally applicable for this project
All rights reserved. can be found under https://github.com/MontiCore/monticore.
This project is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this project. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
--> -->
<!-- (c) https://github.com/MontiCore/monticore -->
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
...@@ -30,7 +19,7 @@ ...@@ -30,7 +19,7 @@
<groupId>de.monticore.lang.monticar</groupId> <groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnn-arch</artifactId> <artifactId>cnn-arch</artifactId>
<version>0.3.3-SNAPSHOT</version> <version>0.3.4-SNAPSHOT</version>
......
...@@ -2,25 +2,14 @@ ...@@ -2,25 +2,14 @@
<!-- <!--
****************************************************************************** (c) https://github.com/MontiCore/monticore
MontiCAR Modeling Family, www.se-rwth.de
Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
All rights reserved.
This project is free software; you can redistribute it and/or The license generally applicable for this project
modify it under the terms of the GNU Lesser General Public can be found under https://github.com/MontiCore/monticore.
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this project. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
--> -->
<!-- (c) https://github.com/MontiCore/monticore -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
...@@ -100,4 +89,4 @@ ...@@ -100,4 +89,4 @@
<activeProfiles> <activeProfiles>
<activeProfile>se-nexus</activeProfile> <activeProfile>se-nexus</activeProfile>
</activeProfiles> </activeProfiles>
</settings> </settings>
\ No newline at end of file
****************************************************************************** (c) https://github.com/MontiCore/monticore
MontiCAR Modeling Family, www.se-rwth.de
Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
All rights reserved.
This project is free software; you can redistribute it and/or The license generally applicable for this project
modify it under the terms of the GNU Lesser General Public can be found under https://github.com/MontiCore/monticore.
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this project. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar; package de.monticore.lang.monticar;
grammar CNNArch extends de.monticore.CommonExpressions, de.monticore.lang.Math, de.monticore.lang.monticar.Common2 { grammar CNNArch extends de.monticore.CommonExpressions, de.monticore.lang.Math, de.monticore.lang.monticar.Common2 {
......
# #
# #
# ****************************************************************************** # (c) https://github.com/MontiCore/monticore
# MontiCAR Modeling Family, www.se-rwth.de
# Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
# All rights reserved.
# #
# This project is free software; you can redistribute it and/or # The license generally applicable for this project
# modify it under the terms of the GNU Lesser General Public # can be found under https://github.com/MontiCore/monticore.
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this project. If not, see <http://www.gnu.org/licenses/>.
# *******************************************************************************
# #
# (c) https://github.com/MontiCore/monticore
#configuration chaniautomation #configuration chaniautomation
VGG16= ./target/data/VGG16/ VGG16= ./target/data/VGG16/
Alexnet= ./target/data/Alexnet/ Alexnet= ./target/data/Alexnet/
\ No newline at end of file
/** /**
* *
* ****************************************************************************** * (c) https://github.com/MontiCore/monticore
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
* *
* This project is free software; you can redistribute it and/or * The license generally applicable for this project
* modify it under the terms of the GNU Lesser General Public * can be found under https://github.com/MontiCore/monticore.
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/ */
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch._ast; package de.monticore.lang.monticar.cnnarch._ast;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables; import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables;
......
/** /**
* *
* ****************************************************************************** * (c) https://github.com/MontiCore/monticore
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
* *
* This project is free software; you can redistribute it and/or * The license generally applicable for this project
* modify it under the terms of the GNU Lesser General Public * can be found under https://github.com/MontiCore/monticore.
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/ */
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch._cocos; package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.monticar.cnnarch._ast.ASTCNNArchNode; import de.monticore.lang.monticar.cnnarch._ast.ASTCNNArchNode;
......
/** /**
* *
* ****************************************************************************** * (c) https://github.com/MontiCore/monticore
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
* *
* This project is free software; you can redistribute it and/or * The license generally applicable for this project
* modify it under the terms of the GNU Lesser General Public * can be found under https://github.com/MontiCore/monticore.
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/ */
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch._cocos; package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol; import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
......
/** /**
* *
* ****************************************************************************** * (c) https://github.com/MontiCore/monticore
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
* *
* This project is free software; you can redistribute it and/or * The license generally applicable for this project
* modify it under the terms of the GNU Lesser General Public * can be found under https://github.com/MontiCore/monticore.
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/ */
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch._cocos; package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.symboltable.Scope; import de.monticore.symboltable.Scope;
......
/** /**
* *
* ****************************************************************************** * (c) https://github.com/MontiCore/monticore
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
* *
* This project is free software; you can redistribute it and/or * The license generally applicable for this project
* modify it under the terms of the GNU Lesser General Public * can be found under https://github.com/MontiCore/monticore.
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/ */
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch._cocos; package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
......
/** /**
* *
* ****************************************************************************** * (c) https://github.com/MontiCore/monticore
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
* *
* This project is free software; you can redistribute it and/or * The license generally applicable for this project
* modify it under the terms of the GNU Lesser General Public * can be found under https://github.com/MontiCore/monticore.
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************