Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CNNArch2Caffe2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
monticore
EmbeddedMontiArc
generators
CNNArch2Caffe2
Commits
e9adcb57
Commit
e9adcb57
authored
Aug 22, 2018
by
Carlos Alfredo Yeverino Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapted Templates Convolution, FullyConnected and Pooling. Added LeNet.cnna model
parent
abeb3c80
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
36 deletions
+26
-36
src/main/resources/templates/caffe2/elements/Convolution.ftl
src/main/resources/templates/caffe2/elements/Convolution.ftl
+5
-6
src/main/resources/templates/caffe2/elements/FullyConnected.ftl
...in/resources/templates/caffe2/elements/FullyConnected.ftl
+4
-2
src/main/resources/templates/caffe2/elements/MaxPooling.ftl
src/main/resources/templates/caffe2/elements/MaxPooling.ftl
+0
-13
src/main/resources/templates/caffe2/elements/Pooling.ftl
src/main/resources/templates/caffe2/elements/Pooling.ftl
+9
-9
src/test/resources/valid_tests/LeNet.cnna
src/test/resources/valid_tests/LeNet.cnna
+8
-6
No files found.
src/main/resources/templates/caffe2/elements/Convolution.ftl
View file @
e9adcb57
<#assign input = element.inputs[0]>
<#if element.padding??>
<#if element.padding??>
<#-- Check wheather padding null is. -->
<#assign input = element.name>
${element.name} = mx.symbol.pad(data=${element.inputs[0]}, #TODO: pending to adapt
mode='constant',
pad_width=(${tc.join(element.padding, ",")}),
constant_value=0)
#TODO: check how to adapt CNNArchLang argument pad_width=${element.padding}
</#if>
${element.name} = brew.conv(model, ${input}, '${element.name}', dim_in=1, dim_out=20, kernel=5)
${element.name} = brew.conv(model, ${input}, '${element.name}', dim_in=1, dim_out=${element.channels?c}, kernel=${element.kernel}, stride=${element.stride})
#TODO: check how to adapt CNNArchLang argument no_bias=${element.noBias?string("True","False")}
#TODO: check how to adapt CNNArchLang argument pad_width=${element.padding}
<#include "OutputShape.ftl">
src/main/resources/templates/caffe2/elements/FullyConnected.ftl
View file @
e9adcb57
<#assign flatten = element.element.inputTypes[0].height != 1 || element.element.inputTypes[0].width != 1>
<#assign input = element.inputs[0]>
<#if flatten>
${element.name} = mx.symbol.flatten(data=${input}) #TODO:
Pending to adapt
${element.name} = mx.symbol.flatten(data=${input}) #TODO:
check how to adapt CNNArchLang flatten
<#assign input = element.name>
</#if>
${element.name} = brew.fc(model, ${input}, '${element.name}', dim_in=50 * 4 * 4, dim_out=500)
${element.name} = brew.fc(model, ${input}, '${element.name}', dim_in=50 * 4 * 4, dim_out=${element.units?c})
#TODO: check how to adapt CNNArchLang argument no_bias=${element.noBias?string("True","False")}
src/main/resources/templates/caffe2/elements/MaxPooling.ftl
deleted
100644 → 0
View file @
abeb3c80
<#assign input = element.inputs[0]>
<#if element.padding??>
<#assign input = element.name>
${element.name} = mx.symbol.pad(data=${element.inputs[0]}, #TODO: Pending to adapt o eliminate
mode='constant',
pad_width=(${tc.join(element.padding, ",")}),
constant_value=0)
</#if>
${element.name} = brew.max_pool(model, ${input}, '${element.name}', kernel=2, stride=2)
src/main/resources/templates/caffe2/elements/Pooling.ftl
View file @
e9adcb57
<#assign input = element.inputs[0]>
<#if element.padding??>
<#assign input = element.name>
${element.name} = mx.symbol.pad(data=${element.inputs[0]},
mode='constant',
pad_width=(${tc.join(element.padding, ",")}),
constant_value=0)
#TODO: check how to adapt CNNArchLang argument pad_width=${element.padding}
</#if>
${element.name} = mx.symbol.Pooling(data=${input},
kernel=(${tc.join(element.kernel, ",")}),
pool_type=${element.poolType},
stride=(${tc.join(element.stride, ",")}),
name="${element.name}")
<#if element.poolType == "max">
${element.name} = brew.max_pool(model, ${input}, '${element.name}', kernel=${element.kernel}, stride=${element.stride})
<#elseif element.poolType == "avg">
${element.name} = brew.average_pool(model, ${input}, '${element.name}', kernel=${element.kernel}, stride=${element.stride})
</#if>
<#include "OutputShape.ftl">
\ No newline at end of file
src/test/resources/valid_tests/LeNet.cnna
View file @
e9adcb57
architecture LeNet(img_height=
28, img_width=28
, img_channels=3, classes=10){
architecture LeNet(img_height=
32, img_width=32
, img_channels=3, classes=10){
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
image ->
Convolution(kernel=(5,5), channels=20, stride=(1,1), padding="no_loss") ->
MaxPooling(kernel=(3,3), stride=(2,2), padding="no_loss") ->
FullyConnected(units=64, no_bias=true) ->
Tanh() ->
FullyConnected(units=classes, no_bias=true) ->
Convolution(kernel=(5,5), channels=20) ->
Pooling(pool_type="max", kernel=(2,2), stride=(2,2)) ->
Convolution(kernel=(5,5), channels=50) ->
Pooling(pool_type="max", kernel=(2,2), stride=(2,2)) ->
FullyConnected(units=500) ->
Relu() ->
FullyConnected(units=classes) ->
Softmax() ->
predictions
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment