docs
docs copied to clipboard
Update MyDense example to use self.add_weight() for proper variable tracking
Fix: Update custom layer example to use self.add_weight()
Problem: The previous MyDense layer created weights with tf.Variable in init. These weights were not automatically registered, so layer.variables and layer.trainable_variables were empty. This breaks standard Keras functionality for training, saving, and inspection.
Solution: Updated MyDense to use self.add_weight(), which properly registers the weights with the layer. Now they appear in .variables and are fully tracked by Keras.
Preview
Preview and run these notebook edits with Google Colab: Rendered notebook diffs available on ReviewNB.com.Format and style
Use the TensorFlow docs notebook tools to format for consistent source diffs and lint for style:$ python3 -m pip install -U --user git+https://github.com/tensorflow/docsIf commits are added to the pull request, synchronize your local branch:
$ python3 -m tensorflow_docs.tools.nbfmt notebook.ipynb
$ python3 -m tensorflow_docs.tools.nblint --arg=repo:tensorflow/docs notebook.ipynb
git pull origin patch-2