Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
CNNArch2Gluon
Commits
f31e54c8
Commit
f31e54c8
authored
Jul 23, 2021
by
lr119628
Browse files
[update] added shaping to CandidateHull
parent
5933c0c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/resources/templates/gluon/elements/AdaNet.ftl
View file @
f31e54c8
...
...
@@ -48,6 +48,7 @@ class CandidateHull(gluon.HybridBlock):
<#else>
input_shape =None,
</#if>
model_shape = <#list Block.outputTypes as type>(${tc.join(type.dimensions, ",")})</#list>,
block_args=None,
**kwargs):
...
...
@@ -58,25 +59,30 @@ class CandidateHull(gluon.HybridBlock):
self.stack = stack
self.rade = None
self.complexity = None
if block_args is None:
body = {name + f'{i}': BuildingBlock() for i in range(self.stack)}
else:
body = {name + f'{i}': BuildingBlock(**block_args) for i in range(self.stack)}
for name in body: # add a new operation to the candidate
val = body[name]
self.__setattr__(name=name, value=val)
self.names.append(name)
self.body = body
if inBlock:
self.input = inBlock()
else:
self.input = None
if output:
self.out = output()
else:
self.out = None
with self.name_scope():
self.output_shape = output_shape
self.input_shape = input_shape
self.model_shape = model_shape
self.classes = prod(list(self.model_shape))
if block_args is None:
body = {name + f'{i}': BuildingBlock() for i in range(self.stack)}
else:
body = {name + f'{i}': BuildingBlock(**block_args) for i in range(self.stack)}
for name in body: # add a new operation to the candidate
val = body[name]
self.__setattr__(name=name, value=val)
self.names.append(name)
self.finalOut = nn.Dense(units=self.classes, activation=None, flatten=False)
self.body = body
if inBlock:
self.input = inBlock()
else:
self.input = None
if output:
self.out = output()
else:
self.out = None
def approximate_rade(self):
"""
...
...
@@ -110,8 +116,9 @@ class CandidateHull(gluon.HybridBlock):
if self.out:
x = self.out(x)
x = self.finalOut(x)
return
x
return
F.reshape(x,shape = self.model_shape)
class BuildingBlock(gluon.HybridBlock):
"""
...
...
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