Skip to content

Fixes monospace formatting for layer subclassing docs #2060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
22 changes: 8 additions & 14 deletions guides/ipynb/making_new_layers_and_models_via_subclassing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@
" self.b = self.add_weight(shape=(units,), initializer=\"zeros\", trainable=True)\n",
"\n",
" def call(self, inputs):\n",
" return ops.matmul(inputs, self.w) + self.b\n",
""
" return ops.matmul(inputs, self.w) + self.b\n"
]
},
{
Expand Down Expand Up @@ -246,8 +245,7 @@
" self.b = self.add_weight(shape=(units,), initializer=\"zeros\", trainable=True)\n",
"\n",
" def call(self, inputs):\n",
" return ops.matmul(inputs, self.w) + self.b\n",
""
" return ops.matmul(inputs, self.w) + self.b\n"
]
},
{
Expand Down Expand Up @@ -289,8 +287,7 @@
" )\n",
"\n",
" def call(self, inputs):\n",
" return ops.matmul(inputs, self.w) + self.b\n",
""
" return ops.matmul(inputs, self.w) + self.b\n"
]
},
{
Expand Down Expand Up @@ -390,7 +387,7 @@
"The `keras.ops` namespace gives you access to:\n",
"\n",
"- The NumPy API, e.g. `ops.matmul`, `ops.sum`, `ops.reshape`, `ops.stack`, etc.\n",
"- Neural networks-specific APIs such as `ops.softmax`, `ops`.conv`, `ops.binary_crossentropy`, `ops.relu`, etc.\n",
"- Neural networks-specific APIs such as `ops.softmax`, `ops.conv`, `ops.binary_crossentropy`, `ops.relu`, etc.\n",
"\n",
"You can also use backend-native APIs in your layers (such as `tf.nn` functions),\n",
"but if you do this, then your layer will only be usable with the backend in question.\n",
Expand Down Expand Up @@ -465,8 +462,7 @@
"\n",
" def call(self, inputs):\n",
" self.add_loss(self.rate * ops.mean(inputs))\n",
" return inputs\n",
""
" return inputs\n"
]
},
{
Expand Down Expand Up @@ -742,8 +738,7 @@
" return keras.random.dropout(\n",
" inputs, rate=self.rate, seed=self.seed_generator\n",
" )\n",
" return inputs\n",
""
" return inputs\n"
]
},
{
Expand Down Expand Up @@ -947,8 +942,7 @@
" z_log_var - ops.square(z_mean) - ops.exp(z_log_var) + 1\n",
" )\n",
" self.add_loss(kl_loss)\n",
" return reconstructed\n",
""
" return reconstructed\n"
]
},
{
Expand Down Expand Up @@ -1010,4 +1004,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
2 changes: 1 addition & 1 deletion guides/making_new_layers_and_models_via_subclassing.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def call(self, inputs):
The `keras.ops` namespace gives you access to:

- The NumPy API, e.g. `ops.matmul`, `ops.sum`, `ops.reshape`, `ops.stack`, etc.
- Neural networks-specific APIs such as `ops.softmax`, `ops`.conv`, `ops.binary_crossentropy`, `ops.relu`, etc.
- Neural networks-specific APIs such as `ops.softmax`, `ops.conv`, `ops.binary_crossentropy`, `ops.relu`, etc.

You can also use backend-native APIs in your layers (such as `tf.nn` functions),
but if you do this, then your layer will only be usable with the backend in question.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ All layers you've seen so far in this guide work with all Keras backends.
The `keras.ops` namespace gives you access to:

- The NumPy API, e.g. `ops.matmul`, `ops.sum`, `ops.reshape`, `ops.stack`, etc.
- Neural networks-specific APIs such as `ops.softmax`, `ops`.conv`, `ops.binary_crossentropy`, `ops.relu`, etc.
- Neural networks-specific APIs such as `ops.softmax`, `ops.conv`, `ops.binary_crossentropy`, `ops.relu`, etc.

You can also use backend-native APIs in your layers (such as `tf.nn` functions),
but if you do this, then your layer will only be usable with the backend in question.
Expand Down