Changing code blocks to use small p Python.
This commit is contained in:
parent
f13ba91f82
commit
5d4c979ef3
@ -48,7 +48,7 @@
|
||||
"\n",
|
||||
"To give a concrete example, in the `mlp.layers` module there is a definition for a `SigmoidLayer` equivalent to the following (documentation strings have been removed here for brevity)\n",
|
||||
"\n",
|
||||
"```Python\n",
|
||||
"```python\n",
|
||||
"class SigmoidLayer(Layer):\n",
|
||||
"\n",
|
||||
" def fprop(self, inputs):\n",
|
||||
@ -67,7 +67,7 @@
|
||||
"\n",
|
||||
"To create a model consisting of an affine transformation followed by applying an elementwise logistic sigmoid transformation we first create a list of the two layer objects (in the order they are applied from inputs to outputs) and then use this to instantiate a new `MultipleLayerModel` object:\n",
|
||||
"\n",
|
||||
"```Python\n",
|
||||
"```python\n",
|
||||
"from mlp.layers import AffineLayer, SigmoidLayer\n",
|
||||
"from mlp.models import MultipleLayerModel\n",
|
||||
"\n",
|
||||
@ -77,7 +77,7 @@
|
||||
"\n",
|
||||
"Because of the modular way in which the layers are defined we can also stack an arbitrarily long sequence of layers together to produce deeper models. For instance the following would define a model consisting of three pairs of affine and logistic sigmoid transformations.\n",
|
||||
"\n",
|
||||
"```Python\n",
|
||||
"```python\n",
|
||||
"model = MultipleLayerModel([\n",
|
||||
" AffineLayer(input_dim, hidden_dim), SigmoidLayer(),\n",
|
||||
" AffineLayer(hidden_dim, hidden_dim), SigmoidLayer(),\n",
|
||||
@ -125,7 +125,7 @@
|
||||
"\n",
|
||||
"This can be efficiently implemented in NumPy using the `dot` function\n",
|
||||
"\n",
|
||||
"```Python\n",
|
||||
"```python\n",
|
||||
"class AffineLayer(LayerWithParameters):\n",
|
||||
"\n",
|
||||
" # ... [implementation of remaining methods from previous week] ...\n",
|
||||
@ -156,7 +156,7 @@
|
||||
"\n",
|
||||
"which you should now be able relate to the implementation of `SigmoidLayer.bprop` given earlier:\n",
|
||||
"\n",
|
||||
"```Python\n",
|
||||
"```python\n",
|
||||
"class SigmoidLayer(Layer):\n",
|
||||
"\n",
|
||||
" def fprop(self, inputs):\n",
|
||||
@ -1343,7 +1343,7 @@
|
||||
"\n",
|
||||
"We are now going to investigate using deeper multiple-layer model archictures for the MNIST classification task. You should experiment with training models with two to five `AffineLayer` transformations interleaved with `SigmoidLayer` nonlinear transformations. Intermediate hidden layers between the input and output should have a dimension of 100. For example the `layers` definition of a model with two `AffineLayer` transformations would be\n",
|
||||
"\n",
|
||||
"```Python\n",
|
||||
"```python\n",
|
||||
"layers = [\n",
|
||||
" AffineLayer(input_dim, 100),\n",
|
||||
" SigmoidLayer(),\n",
|
||||
|
Loading…
Reference in New Issue
Block a user