Adding example Gaussian Noise model
parent
fd4c180f93
commit
757fb650a2
|
@ -1900,7 +1900,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 147,
|
"execution_count": 2,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
@ -1922,7 +1922,36 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"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": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
@ -3883,7 +3912,7 @@
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.7.10"
|
"version": "3.8.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
Loading…
Reference in New Issue