diff --git a/site/en/guide/intro_to_modules.ipynb b/site/en/guide/intro_to_modules.ipynb index 79bbe89ca5..1d329c5d17 100644 --- a/site/en/guide/intro_to_modules.ipynb +++ b/site/en/guide/intro_to_modules.ipynb @@ -748,9 +748,18 @@ " super().__init__(**kwargs)\n", "\n", " # This will soon move to the build step; see below\n", - " self.w = tf.Variable(\n", - " tf.random.normal([in_features, out_features]), name='w')\n", - " self.b = tf.Variable(tf.zeros([out_features]), name='b')\n", + " self.w = self.add_weight( + shape=(in_features, out_features), + initializer="random_normal", + trainable=True, + name="w" + ) + self.b = self.add_weight( + shape=(out_features,), + initializer="zeros", + trainable=True, + name="b" + ) " def call(self, x):\n", " y = tf.matmul(x, self.w) + self.b\n", " return tf.nn.relu(y)\n",