Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CNNArch2Gluon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
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
Package Registry
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
CNNArch2Gluon
Commits
2990a673
Commit
2990a673
authored
Mar 06, 2020
by
Julian Treiber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added metric AccuracyWithIgnoreLabel
parent
02624b4a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletion
+37
-1
src/main/resources/templates/gluon/CNNSupervisedTrainer.ftl
src/main/resources/templates/gluon/CNNSupervisedTrainer.ftl
+27
-0
src/main/resources/templates/gluon/CNNTrainer.ftl
src/main/resources/templates/gluon/CNNTrainer.ftl
+6
-0
src/main/resources/templates/gluon/gan/Trainer.ftl
src/main/resources/templates/gluon/gan/Trainer.ftl
+4
-1
No files found.
src/main/resources/templates/gluon/CNNSupervisedTrainer.ftl
View file @
2990a673
...
...
@@ -87,6 +87,33 @@ class DiceLoss(gluon.loss.Loss):
diceloss = self.dice_loss(F, pred, label)
return F.mean(loss, axis=self._batch_axis, exclude=True) + diceloss
@mx.metric.register
class ACCURACY_IGNORE_LABEL(mx.metric.EvalMetric):
def __init__(self, axis=1, ignore_label=255, name='accuracy',
output_names=None, label_names=None):
super(ACCURACY_IGNORE_LABEL, self).__init__(
name, axis=axis,
output_names=output_names, label_names=label_names)
self.axis = axis
self.ignore_label = ignore_label
def update(self, labels, preds):
mx.metric.check_label_shapes(labels, preds)
for label, pred_label in zip(labels, preds):
if pred_label.shape != label.shape:
pred_label = mx.nd.argmax(pred_label, axis=self.axis, keepdims=True)
label = label.astype('int32')
pred_label = pred_label.astype('int32').as_in_context(label.context)
mx.metric.check_label_shapes(label, pred_label)
correct = mx.nd.sum( (label == pred_label) * (label != self.ignore_label) ).asscalar()
total = mx.nd.sum( (label != self.ignore_label) ).asscalar()
self.sum_metric += correct
self.num_inst += total
@mx.metric.register
class BLEU(mx.metric.EvalMetric):
N = 4
...
...
src/main/resources/templates/gluon/CNNTrainer.ftl
View file @
2990a673
...
...
@@ -66,6 +66,12 @@ if __name__ == "__main__":
eval_metric_params={
<#if (config.evalMetric.exclude)??>
'exclude': [<#list config.evalMetric.exclude as value>${value}<#sep>, </#list>],
</#if>
<#if (config.evalMetric.exclude)??>
'axis': ${config.evalMetric.axis},
</#if>
<#if (config.evalMetric.exclude)??>
'ignore_label': ${config.evalMetric.ignore_label},
</#if>
},
</#if>
...
...
src/main/resources/templates/gluon/gan/Trainer.ftl
View file @
2990a673
...
...
@@ -65,7 +65,10 @@ if __name__ == "__main__":
preprocessing=${config.preprocessor?string("True","False")},
</#if>
<#if (config.evalMetric)??>
eval_metric='${config.evalMetric}',
eval_metric='${config.evalMetric.name}',
eval_metric_params={
<#if (config.evalMetric.exclude)??>
'exclude': [<#list config.evalMetric.exclude as value>${value}<#sep>, </#list>],
</#if>
<#if (config.configuration.optimizer)??>
optimizer='${config.optimizerName}',
...
...
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