Skip to content

Commit eb17118

Browse files
author
rbodo
committed
Fixed top-k accuracy in parsed model which was hardcoded to the default value.
1 parent 0e2a2d8 commit eb17118

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

snntoolbox/parsing/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,9 +812,10 @@ def build_parsed_model(self):
812812
self.parsed_model = keras.models.Model(img_input, parsed_layers[
813813
self._layer_list[-1]['name']])
814814
# Optimizer and loss do not matter because we only do inference.
815-
self.parsed_model.compile(
816-
'sgd', 'categorical_crossentropy',
817-
['accuracy', keras.metrics.top_k_categorical_accuracy])
815+
top_k = lambda x, y: keras.metrics.top_k_categorical_accuracy(
816+
x, y, self.config.getint('simulation', 'top_k'))
817+
self.parsed_model.compile('sgd', 'categorical_crossentropy',
818+
['accuracy', top_k])
818819
# Todo: Enable adding custom metric via self.input_model.metrics.
819820
self.parsed_model.summary()
820821
return self.parsed_model

0 commit comments

Comments
 (0)