tf.keras.backend.count_params

TensorFlow 1 version View source on GitHub

Returns the static number of elements in a variable or tensor.

tf.keras.backend.count_params(x)

Arguments:

  • x: Variable or tensor.

Returns:

Integer, the number of scalars in x.

Example:

<pre class="devsite-click-to-copy prettyprint lang-py">
<code class="devsite-terminal" data-terminal-prefix="&gt;&gt;&gt;">kvar = K.zeros((2,3))</code>
<code class="no-select nocode">    &gt;&gt;&gt; K.count_params(kvar)</code>
<code class="no-select nocode">    6</code>
<code class="no-select nocode">    &gt;&gt;&gt; K.eval(kvar)</code>
<code class="no-select nocode">    array([[ 0.,  0.,  0.],</code>
<code class="no-select nocode">           [ 0.,  0.,  0.]], dtype=float32)</code>
</pre>

Compat aliases