diff --git a/12_custom_models_and_training_with_tensorflow.ipynb b/12_custom_models_and_training_with_tensorflow.ipynb index bc0fde2..c3c34af 100644 --- a/12_custom_models_and_training_with_tensorflow.ipynb +++ b/12_custom_models_and_training_with_tensorflow.ipynb @@ -1963,7 +1963,7 @@ }, { "cell_type": "code", - "execution_count": 147, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -1985,7 +1985,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": [