...
 
Commits (8)
#
#
# ******************************************************************************
# 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
# 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
# Java Maven CircleCI 2.0 configuration file
#
......
#
#
# ******************************************************************************
# 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
# 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
stages:
- windows
......
# (c) https://github.com/MontiCore/monticore
script:
- git checkout ${TRAVIS_BRANCH}
- 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/generators/CNNArch2Caffe2/badges/master/build.svg)
![coverage](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/CNNArch2Caffe2/badges/master/coverage.svg)
......
<!-- (c) https://github.com/MontiCore/monticore -->
<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">
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
<!-- (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
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/>.
*******************************************************************************
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
......
(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.
The license generally applicable for this project
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/>.
*******************************************************************************
/**
*
* ******************************************************************************
* 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
* 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 */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureElementSymbol;
......
/**
*
* ******************************************************************************
* 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
* 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 */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.lang.monticar.cnnarch.generator.CNNArchGenerator;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.lang.monticar.cnnarch.generator.ArchitectureSupportChecker;
......
/**
*
* ******************************************************************************
* 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
* 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 */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.lang.monticar.cnnarch.generator.CNNArchGenerator;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedLayers;
......
/**
*
* ******************************************************************************
* 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
* 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 */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.lang.monticar.cnnarch.generator.TrainParamSupportChecker;
......@@ -75,4 +56,4 @@ public class CNNArch2Caffe2TrainParamSupportChecker extends TrainParamSupportChe
this.unsupportedElemList.add(node.getName());
}
}
\ No newline at end of file
}
/**
*
* ******************************************************************************
* 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
* 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 */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.lang.monticar.cnnarch.generator.LayerNameCreator;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.io.paths.ModelPath;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.lang.monticar.cnntrain._symboltable.*;
......
/**
*
* ******************************************************************************
* 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
* 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 */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.se_rwth.commons.logging.Log;
......
<#-- (c) https://github.com/MontiCore/monticore -->
from caffe2.python import workspace, core, model_helper, brew, optimizer
from caffe2.python.predictor import mobile_exporter
from caffe2.proto import caffe2_pb2
......
<#-- (c) https://github.com/MontiCore/monticore -->
#ifndef ${tc.fileNameWithoutEnding?upper_case}
#define ${tc.fileNameWithoutEnding?upper_case}
......
<#-- (c) https://github.com/MontiCore/monticore -->
from caffe2.python import workspace, core, model_helper, brew, optimizer
from caffe2.python.predictor import mobile_exporter
from caffe2.proto import caffe2_pb2
......
<#-- (c) https://github.com/MontiCore/monticore -->
<#-- This layer is currently not supported -->
<#-- (c) https://github.com/MontiCore/monticore -->
<#-- This layer is currently not supported -->
<#-- (c) https://github.com/MontiCore/monticore -->
<#-- This layer is currently not supported -->
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
<#assign strideHeight = element.stride[0]>
<#assign strideWidth = element.stride[1]>
......@@ -23,4 +24,4 @@
<#assign kernelParameter = "kernel=[${kernelHeight},${kernelWidth}]">
</#if>
${element.name} = brew.conv(model, ${input}, '${element.name}', dim_in=${element.element.inputTypes[0].channels?c}, dim_out=${element.channels?c}, ${kernelParameter}, ${strideParameter}${padParameter})
<#include "OutputShape.ftl">
\ No newline at end of file
<#include "OutputShape.ftl">
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
<#assign ratio = element.p?c?string>
${element.name} = brew.dropout(model, ${input}, '${element.name}', ratio=${ratio}, is_test=False)
${element.name} = model.net.Flatten(${element.inputs[0]}, "${element.name}")
\ No newline at end of file
<#-- (c) https://github.com/MontiCore/monticore -->
${element.name} = model.net.Flatten(${element.inputs[0]}, "${element.name}")
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign flatten = element.element.inputTypes[0].height != 1 || element.element.inputTypes[0].width != 1>
<#assign input = element.inputs[0]>
<#assign inputLayerType = element.element.getInputElement().get()?string>
......@@ -10,4 +11,4 @@
<#else>
${element.name} = brew.fc(model, ${input}, '${element.name}', dim_in=${inputChannels} * ${inputHeight} * ${inputWidth}, dim_out=${element.units?c})
</#if>
<#include "OutputShape.ftl">
\ No newline at end of file
<#include "OutputShape.ftl">
<#-- (c) https://github.com/MontiCore/monticore -->
<#-- This layer is currently not supported -->
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
<#if element.poolType == "max">
${element.name} = brew.max_pool(model, ${input}, '${element.name}', global_pooling=True)
<#elseif element.poolType == "avg">
${element.name} = brew.average_pool(model, ${input}, '${element.name}', global_pooling=True)
</#if>
<#include "OutputShape.ftl">
\ No newline at end of file
<#include "OutputShape.ftl">
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign channelIndex = element.element.outputTypes[0].channelIndex + 1>
<#assign heightIndex = element.element.outputTypes[0].heightIndex + 1>
<#assign widthIndex = element.element.outputTypes[0].widthIndex + 1>
......
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
<#if !element.knorm?string?contains(".")>
<#assign bias = element.knorm?string["0.0"]>
......
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
<#if element.softmaxOutput>
${element.name} = brew.softmax(model, ${input}, '${element.name}')
......@@ -7,4 +8,4 @@
${element.name} = ${input}
</#if>
return ${element.name}
\ No newline at end of file
return ${element.name}
<#-- (c) https://github.com/MontiCore/monticore -->
# ${element.name}, output shape: {<#list element.element.outputTypes as type>[${tc.join(type.dimensions, ",")}]</#list>}
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
<#assign strideHeight = element.stride[0]>
<#assign strideWidth = element.stride[1]>
......@@ -27,4 +28,4 @@
<#elseif element.poolType == "avg">
${element.name} = brew.average_pool(model, ${input}, '${element.name}', ${kernelParameter}, ${strideParameter}${padParameter})
</#if>
<#include "OutputShape.ftl">
\ No newline at end of file
<#include "OutputShape.ftl">
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
${element.name} = brew.relu(model, ${input}, ${input})
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
${element.name} = model.net.Sigmoid(${input}, '${element.name}')
<#-- (c) https://github.com/MontiCore/monticore -->
<#-- This template is not used if the followiing architecture element is an output. See Output.ftl -->
<#assign input = element.inputs[0]>
${element.name} = brew.softmax(model, ${input}, '${element.name}')
<#-- (c) https://github.com/MontiCore/monticore -->
<#-- This layer is currently not supported -->
<#-- (c) https://github.com/MontiCore/monticore -->
<#assign input = element.inputs[0]>
${element.name} = brew.tanh(model, ${input}, ${input})
<#-- (c) https://github.com/MontiCore/monticore -->
<#list tc.architecture.outputs as output>
<#assign shape = output.ioDeclaration.type.dimensions>
vector<float> CNN_${tc.getName(output)}(<#list shape as dim>${dim?c}<#if dim?has_next>*</#if></#list>);
......
/**
*
* ******************************************************************************
* 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
* 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 */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.ModelingLanguageFamily;
......
/**
*
* ******************************************************************************
* 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
* 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 */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.se_rwth.commons.logging.Log;
......
/**
*
* ******************************************************************************
* 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
* 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 */
package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.lang.monticar.cnnarch._parser.CNNArchParser;
......
/* (c) https://github.com/MontiCore/monticore */
architecture Alexnet(img_height=224, img_width=224, img_channels=3, classes=10){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} predictions
......@@ -40,4 +41,4 @@ architecture Alexnet(img_height=224, img_width=224, img_channels=3, classes=10){
FullyConnected(units=10) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture LeNet(img_height=28, img_width=28, img_channels=1, classes=10){
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
......@@ -12,4 +13,4 @@ architecture LeNet(img_height=28, img_width=28, img_channels=1, classes=10){
FullyConnected(units=classes) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture ResNeXt50(img_height=224, img_width=224, img_channels=3, classes=1000){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} predictions
......@@ -41,4 +42,4 @@ architecture ResNeXt50(img_height=224, img_width=224, img_channels=3, classes=10
FullyConnected(units=classes) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture ResNet152(img_height=224, img_width=224, img_channels=3, classes=1000){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} predictions
......@@ -34,4 +35,4 @@ architecture ResNet152(img_height=224, img_width=224, img_channels=3, classes=10
FullyConnected(units=classes) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture ResNet34(img_height=224, img_width=224, img_channels=3, classes=1000){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} predictions
......
/* (c) https://github.com/MontiCore/monticore */
architecture SequentialAlexnet(img_height=224, img_width=224, img_channels=3, classes=10){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} predictions
......
/* (c) https://github.com/MontiCore/monticore */
architecture ThreeInputCNN_M14(img_height=200, img_width=300, img_channels=3, classes=3){
/*CNN used for flower grading. Model 14 of the paper.
*Title: Multi-Input Convolutional Neural Network for Flower Grading
......@@ -29,4 +30,4 @@ architecture ThreeInputCNN_M14(img_height=200, img_width=300, img_channels=3, cl
FullyConnected(units=classes) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture VGG16(img_height=224, img_width=224, img_channels=3, classes=1000){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} predictions
......@@ -28,4 +29,4 @@ architecture VGG16(img_height=224, img_width=224, img_channels=3, classes=1000){
FullyConnected(units=classes) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
......@@ -4,4 +4,4 @@ LeNet data/LeNet
VGG16 data/VGG16
MultipleOutputs data/MultipleOutputs
ResNeXt50 data/ResNeXt50
ThreeInputCNN_M14 data/ThreeInputCNN_M14
\ No newline at end of file
ThreeInputCNN_M14 data/ThreeInputCNN_M14
# (c) https://github.com/MontiCore/monticore
from caffe2.python import workspace, core, model_helper, brew, optimizer
from caffe2.python.predictor import mobile_exporter
from caffe2.proto import caffe2_pb2
......@@ -263,4 +264,4 @@ class CNNCreator_Alexnet:
net_def.ParseFromString(f.read())
net_def.device_option.CopyFrom(device_opts)
workspace.CreateNet(net_def.SerializeToString(), overwrite=True)
print("== Loaded init_net and predict_net ==")
\ No newline at end of file
print("== Loaded init_net and predict_net ==")
# (c) https://github.com/MontiCore/monticore
from caffe2.python import workspace, core, model_helper, brew, optimizer
from caffe2.python.predictor import mobile_exporter
from caffe2.proto import caffe2_pb2
......@@ -291,4 +292,4 @@ class CNNCreator_CifarClassifierNetwork:
net_def.ParseFromString(f.read())
net_def.device_option.CopyFrom(device_opts)
workspace.CreateNet(net_def.SerializeToString(), overwrite=True)
print("== Loaded init_net and predict_net ==")
\ No newline at end of file
print("== Loaded init_net and predict_net ==")
......@@ -91,6 +91,7 @@ class CNNCreator_LeNet:
return predictions_
# this adds the loss and optimizer
def add_training_operators(self, model, output, label, device_opts, loss, opt_type, base_learning_rate, policy, stepsize, epsilon, beta1, beta2, gamma, momentum) :
with core.DeviceScope(device_opts):
......
......@@ -137,6 +137,7 @@ class CNNCreator_VGG16:
return predictions_
# this adds the loss and optimizer
def add_training_operators(self, model, output, label, device_opts, loss, opt_type, base_learning_rate, policy, stepsize, epsilon, beta1, beta2, gamma, momentum) :
with core.DeviceScope(device_opts):
......
/* (c) https://github.com/MontiCore/monticore */
#ifndef CNNPREDICTOR_ALEXNET
#define CNNPREDICTOR_ALEXNET
......@@ -114,4 +115,4 @@ class CNNPredictor_Alexnet_0{
}
};
#endif // CNNPREDICTOR_ALEXNET
\ No newline at end of file
#endif // CNNPREDICTOR_ALEXNET
/* (c) https://github.com/MontiCore/monticore */
#ifndef CNNPREDICTOR_CIFARCLASSIFIERNETWORK
#define CNNPREDICTOR_CIFARCLASSIFIERNETWORK
......@@ -114,4 +115,4 @@ class CNNPredictor_CifarClassifierNetwork_0{
}
};
#endif // CNNPREDICTOR_CIFARCLASSIFIERNETWORK
\ No newline at end of file
#endif // CNNPREDICTOR_CIFARCLASSIFIERNETWORK
......@@ -3,4 +3,4 @@
_predictor_0_.predict(CNNTranslator::translate(data),
CNN_predictions);
predictions = CNNTranslator::translateToCol(CNN_predictions, std::vector<size_t> {10});
\ No newline at end of file
predictions = CNNTranslator::translateToCol(CNN_predictions, std::vector<size_t> {10});
......@@ -3,4 +3,4 @@
_predictor_0_.predict(CNNTranslator::translate(data),
CNN_softmax);
softmax = CNNTranslator::translateToCol(CNN_softmax, std::vector<size_t> {10});
\ No newline at end of file
softmax = CNNTranslator::translateToCol(CNN_softmax, std::vector<size_t> {10});
/* (c) https://github.com/MontiCore/monticore */
architecture Alexnet_alt(img_height=224, img_width=224, img_channels=3, classes=10){
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
......@@ -50,4 +51,4 @@ architecture Alexnet_alt(img_height=224, img_width=224, img_channels=3, classes=
FullyConnected(units=classes) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture Alexnet_alt2(img_height=224, img_width=224, img_channels=3, classes=10){
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
......@@ -36,4 +37,4 @@ architecture Alexnet_alt2(img_height=224, img_width=224, img_channels=3, classes
FullyConnected(units=classes) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture ArgumentSequenceTest {
def input Z(0:255)^{3, 224, 224} image
def output Q(0:1)^{10} predictions
......@@ -10,4 +11,4 @@ architecture ArgumentSequenceTest {
FullyConnected(units=10) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture CifarClassifierNetwork(classes=10){
def input Z(0:255)^{3, 32, 32} data
def output Q(0:1)^{classes} softmax
......@@ -32,4 +33,4 @@ architecture CifarClassifierNetwork(classes=10){
FullyConnected(units=classes) ->
Softmax() ->
softmax;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
configuration EmptyConfig{
}
/* (c) https://github.com/MontiCore/monticore */
architecture Fixed_Alexnet(){
def input Z(0:255)^{3, 224, 224} image
def output Q(0:1)^{10} predictions
......@@ -40,4 +41,4 @@ architecture Fixed_Alexnet(){
FullyConnected(units=10) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture Fixed_ThreeInputCNN_M14(){
def input Z(0:255)^{3, 200, 300} image[3]
def output Q(0:1)^{3} predictions
......@@ -24,4 +25,4 @@ architecture Fixed_ThreeInputCNN_M14(){
FullyConnected(units=3) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
configuration FullConfig{
num_epoch : 5
batch_size : 100
......
/* (c) https://github.com/MontiCore/monticore */
architecture MultipleOutputs{
def input Q(-oo:+oo)^{10} data
def output Q(0:1)^{4} pred[2]
......@@ -18,4 +19,4 @@ architecture MultipleOutputs{
) ->
pred;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture ResNeXt50_InstanceTest(img_height=224, img_width=224, img_channels=3, classes=1000, cardinality=32){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} predictions
......@@ -41,4 +42,4 @@ architecture ResNeXt50_InstanceTest(img_height=224, img_width=224, img_channels=
FullyConnected(units=classes) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture ResNeXt50_alt(img_height=224, img_width=224, img_channels=3, classes=1000){
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
......@@ -43,4 +44,4 @@ architecture ResNeXt50_alt(img_height=224, img_width=224, img_channels=3, classe
FullyConnected(units=classes) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture ResNet152_alt(img_height=224, img_width=224, img_channels=3, classes=1000){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} predictions
......@@ -37,4 +38,4 @@ architecture ResNet152_alt(img_height=224, img_width=224, img_channels=3, classe
FullyConnected(units=classes) ->
Softmax() ->
predictions;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
configuration SimpleConfig{
num_epoch : 50
batch_size : 100
......
/* (c) https://github.com/MontiCore/monticore */
architecture SimpleNetworkLinear(inputs=10, classes=2){
def input Q(-oo:+oo)^{inputs} in1
def output Q(-oo:oo)^{classes} out1
......@@ -7,4 +8,4 @@ architecture SimpleNetworkLinear(inputs=10, classes=2){
Tanh() ->
FullyConnected(units=classes, no_bias=true) ->
out1;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture SimpleNetworkRelu(inputs=10, classes=2){
def input Q(-oo:+oo)^{inputs} in1
def output Q(0:oo)^{classes} out1
......@@ -8,4 +9,4 @@ architecture SimpleNetworkRelu(inputs=10, classes=2){
FullyConnected(units=classes, no_bias=true) ->
Relu() ->
out1;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture SimpleNetworkSigmoid(inputs=10, classes=2){
def input Q(-oo:+oo)^{inputs} in1
def output Q(0:1)^{classes} out1
......@@ -8,4 +9,4 @@ architecture SimpleNetworkSigmoid(inputs=10, classes=2){
FullyConnected(units=classes, no_bias=true) ->
Sigmoid() ->
out1;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture SimpleNetworkSoftmax(inputs=10, classes=2){
def input Q(-oo:+oo)^{inputs} in1
def output Q(0:1)^{classes} out1
......@@ -8,4 +9,4 @@ architecture SimpleNetworkSoftmax(inputs=10, classes=2){
FullyConnected(units=classes, no_bias=true) ->
Softmax() ->
out1;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture SimpleNetworkTanh(inputs=10, classes=2){
def input Q(-oo:+oo)^{inputs} in1
def output Q(-1:1)^{classes} out1
......@@ -8,4 +9,4 @@ architecture SimpleNetworkTanh(inputs=10, classes=2){
FullyConnected(units=classes, no_bias=true) ->
Tanh() ->
out1;
}
\ No newline at end of file
}
/* (c) https://github.com/MontiCore/monticore */
architecture ThreeInputCNN_M14_alternative(img_height=200, img_width=300, img_channels=3, classes=3){
/*CNN used for flower grading. Model 14 of the paper.
*Title: Multi-Input Convolutional Neural Network for Flower Grading
......
/* (c) https://github.com/MontiCore/monticore */
configuration UnsupportedConfig{
num_epoch : 5
batch_size : 100
......@@ -9,4 +10,4 @@ configuration UnsupportedConfig{
rescale_grad : 1.1
clip_gradient : 10
}
}
\ No newline at end of file
}
......@@ -2,4 +2,4 @@ Alexnet data/Alexnet
CifarClassifierNetwork data/CifarClassifierNetwork
LeNet data/LeNet
VGG16 data/VGG16
MultipleOutputs data/MultipleOutputs
\ No newline at end of file
MultipleOutputs data/MultipleOutputs