mirror of
https://github.com/ArthurDanjou/handson-ml3.git
synced 2026-01-14 12:14:36 +01:00
Adding example Gaussian Noise model
This commit is contained in:
@@ -1900,7 +1900,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 147,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -1922,7 +1922,36 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 148,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class GaussianNoiseModel(keras.Model):\n",
|
||||
" def __init__(self, units, activation, **kwargs):\n",
|
||||
" super(GaussianNoiseModel, self).__init__(**kwargs)\n",
|
||||
" self.noise = AddGaussianNoise(stddev=1.0)\n",
|
||||
" self.hidden = keras.layers.Dense(units, activation=activation)\n",
|
||||
" self.out = keras.layers.Dense(1)\n",
|
||||
" \n",
|
||||
" def call(self, inputs):\n",
|
||||
" noise = self.noise(inputs)\n",
|
||||
" hidden = self.hidden(noise)\n",
|
||||
" out = self.out(hidden)\n",
|
||||
" return out"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"model = GaussianNoiseModel(units=30, activation='selu')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -3883,7 +3912,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.10"
|
||||
"version": "3.8.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user