MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / count_params

Method count_params

tensorflow/python/keras/engine/base_layer.py:1633–1652  ·  view source on GitHub ↗

Count the total number of scalars composing the weights. Returns: An integer count. Raises: ValueError: if the layer isn't yet built (in which case its weights aren't yet defined).

(self)

Source from the content-addressed store, hash-verified

1631 'instead.')
1632
1633 def count_params(self):
1634 """Count the total number of scalars composing the weights.
1635
1636 Returns:
1637 An integer count.
1638
1639 Raises:
1640 ValueError: if the layer isn't yet built
1641 (in which case its weights aren't yet defined).
1642 """
1643 if not self.built:
1644 if getattr(self, '_is_graph_network', False):
1645 with tf_utils.maybe_init_scope(self):
1646 self._maybe_build(self.inputs)
1647 else:
1648 raise ValueError('You tried to call `count_params` on ' + self.name +
1649 ', but the layer isn\'t built. '
1650 'You can build it manually via: `' + self.name +
1651 '.build(batch_input_shape)`.')
1652 return int(sum(np.prod(w.shape.as_list()) for w in self.weights))
1653
1654 @property
1655 def output_shape(self):

Callers 5

test_count_paramsMethod · 0.80
test_count_paramsMethod · 0.80
print_layer_summaryFunction · 0.80
test_count_paramsMethod · 0.80

Calls 3

_maybe_buildMethod · 0.95
sumFunction · 0.85
as_listMethod · 0.45

Tested by 3

test_count_paramsMethod · 0.64
test_count_paramsMethod · 0.64
test_count_paramsMethod · 0.64