Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions site/en/guide/intro_to_modules.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down