Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CNNArch2Gluon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
monticore
EmbeddedMontiArc
generators
CNNArch2Gluon
Commits
a132a0fa
Commit
a132a0fa
authored
5 years ago
by
Sebastian Nickels
Browse files
Options
Downloads
Patches
Plain Diff
Updated for NetworkInstructionSymbol
parent
c0574e47
No related branches found
Branches containing commit
No related tags found
1 merge request
!23
Added Unroll-related features and layers
Pipeline
#180400
failed
5 years ago
Stage: windows
Stage: linux
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/resources/templates/gluon/CNNCreator.ftl
+9
-24
9 additions, 24 deletions
src/main/resources/templates/gluon/CNNCreator.ftl
src/main/resources/templates/gluon/CNNNet.ftl
+8
-25
8 additions, 25 deletions
src/main/resources/templates/gluon/CNNNet.ftl
with
17 additions
and
49 deletions
src/main/resources/templates/gluon/CNNCreator.ftl
+
9
−
24
View file @
a132a0fa
...
...
@@ -2,15 +2,9 @@ import mxnet as mx
import
logging
import
os
<#
list
tc.architecture.streams as stream>
<#
if
stream.isTrainable()>
from
CNNNet_$
{
tc
.fullArchitectureName
}
import Net_$
{
stream
?
index
}
</#
if
>
</#
list
>
<#
list
tc.architecture.unrolls as unroll>
<#
if
unroll.body.isTrainable()>
from
CNNNet_$
{
tc
.fullArchitectureName
}
import Net_$
{
tc
.architecture.streams
?
size
+
unroll
?
index
}
<#
list
tc.architecture.networkInstructions as networkInstruction>
<#
if
networkInstruction.body.isTrainable()>
from
CNNNet_$
{
tc
.fullArchitectureName
}
import Net_$
{
networkInstruction
?
index
}
</#
if
>
</#
list
>
...
...
@@ -58,21 +52,12 @@ class ${tc.fileNameWithoutEnding}:
return earliestLastEpoch
def construct(self, context, data_mean=None, data_std=None):
<#
list
tc.architecture.streams as stream>
<#
if
stream.isTrainable()>
self.networks[$
{
stream
?
index
}
] = Net_$
{
stream
?
index
}
(data_mean=data_mean, data_std=data_std)
self.networks[$
{
stream
?
index
}
].collect_params().initialize(self.weight_initializer, ctx=context)
self.networks[$
{
stream
?
index
}
].hybridize()
self.networks[$
{
stream
?
index
}
](<#list tc.getStreamInputDimensions(stream) as dimensions>mx.nd.zeros(($
{
tc
.join
(
dimensions
,
","
)}
,), ctx=context)<#sep>, </#list>)
</#
if
>
</#
list
>
<#
list
tc.architecture.unrolls as unroll>
<#
if
unroll.body.isTrainable()>
self.networks[$
{
tc
.architecture.streams
?
size
+
unroll
?
index
}
] = Net_$
{
tc
.architecture.streams
?
size
+
unroll
?
index
}
(data_mean=data_mean, data_std=data_std)
self.networks[$
{
tc
.architecture.streams
?
size
+
unroll
?
index
}
].collect_params().initialize(self.weight_initializer, ctx=context)
self.networks[$
{
tc
.architecture.streams
?
size
+
unroll
?
index
}
].hybridize()
self.networks[$
{
tc
.architecture.streams
?
size
+
unroll
?
index
}
](<#list tc.getStreamInputDimensions(unroll.body) as dimensions>mx.nd.zeros(($
{
tc
.join
(
dimensions
,
","
)}
,), ctx=context)<#sep>, </#list>)
<#
list
tc.architecture.networkInstructions as networkInstruction>
<#
if
networkInstruction.body.isTrainable()>
self.networks[$
{
networkInstruction
?
index
}
] = Net_$
{
networkInstruction
?
index
}
(data_mean=data_mean, data_std=data_std)
self.networks[$
{
networkInstruction
?
index
}
].collect_params().initialize(self.weight_initializer, ctx=context)
self.networks[$
{
networkInstruction
?
index
}
].hybridize()
self.networks[$
{
networkInstruction
?
index
}
](<#list tc.getStreamInputDimensions(networkInstruction.body) as dimensions>mx.nd.zeros(($
{
tc
.join
(
dimensions
,
","
)}
,), ctx=context)<#sep>, </#list>)
</#
if
>
</#
list
>
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/templates/gluon/CNNNet.ftl
+
8
−
25
View file @
a132a0fa
...
...
@@ -78,35 +78,18 @@ class NoNormalization(gluon.HybridBlock):
return x
<#
list
tc.architecture.
streams as stream
>
<#
if
stream
.isTrainable()>
class
Net_$
{
stream
?
index
}
(gluon.HybridBlock):
<#
list
tc.architecture.
networkInstructions as networkInstruction
>
<#
if
networkInstruction.body
.isTrainable()>
class
Net_$
{
networkInstruction
?
index
}
(gluon.HybridBlock):
def __init__(self, data_mean=None, data_std=None,
**
kwargs):
super(Net_$
{
stream
?
index
}
, self).__init__(
**
kwargs)
super(Net_$
{
networkInstruction
?
index
}
, self).__init__(
**
kwargs)
self.last_layers =
{}
with self.name_scope():
${
tc
.include
(
stream
,
"ARCHITECTURE_DEFINITION")
}
${
tc
.include
(
networkInstruction
.body
,
"ARCHITECTURE_DEFINITION")
}
def hybrid_forward(self, F, $
{
tc
.join
(
tc
.getStreamInputNames
(
stream
),
", "
)}
):
${
tc
.include
(
stream
,
"FORWARD_FUNCTION")
}
return $
{
tc
.join
(
tc
.getStreamOutputNames
(
stream
),
", "
)}
</#
if
>
</#
list
>
<#
list
tc.architecture.unrolls as unroll>
<#
if
unroll.body.isTrainable()>
class
Net_$
{
unroll
?
index
}
(gluon.HybridBlock):
def __init__(self, data_mean=None, data_std=None,
**
kwargs):
super(Net_$
{
unroll
?
index
}
, self).__init__(
**
kwargs)
self.last_layers =
{}
with self.name_scope():
${
tc
.include
(
unroll
.body
,
"ARCHITECTURE_DEFINITION")
}
def hybrid_forward(self, F, $
{
tc
.join
(
tc
.getStreamInputNames
(
unroll
.body
),
", "
)}
):
${
tc
.include
(
unroll
.body
,
"FORWARD_FUNCTION")
}
return $
{
tc
.join
(
tc
.getStreamOutputNames
(
unroll
.body
),
", "
)}
def hybrid_forward(self, F, $
{
tc
.join
(
tc
.getStreamInputNames
(
networkInstruction
.body
),
", "
)}
):
${
tc
.include
(
networkInstruction
.body
,
"FORWARD_FUNCTION")
}
return $
{
tc
.join
(
tc
.getStreamOutputNames
(
networkInstruction
.body
),
", "
)}
</#
if
>
</#
list
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment