Skip to content

Commit

Permalink
Big fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sandersk authored Oct 10, 2024
1 parent 6b245e3 commit 6a9e1a3
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions ml/cc/exercises/representation_with_a_feature_cross.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
" model = tf.keras.Model(inputs=my_inputs, outputs=my_outputs)\n",
"\n",
" # Construct the layers into a model that TensorFlow can execute.\n",
" model.compile(optimizer=tf.keras.optimizers.experimental.RMSprop(\n",
" model.compile(optimizer=tf.keras.optimizers.RMSprop(\n",
" learning_rate=my_learning_rate),\n",
" loss=\"mean_squared_error\",\n",
" metrics=[tf.keras.metrics.RootMeanSquaredError()])\n",
Expand Down Expand Up @@ -282,16 +282,12 @@
"\n",
"# The two Input layers are concatenated so they can be passed as a single\n",
"# tensor to a Dense layer.\n",
"preprocessing_layer = tf.keras.layers.Concatenate()(inputs.values())\n",
"preprocessing_layer = tf.keras.layers.Concatenate()(list(inputs.values()))\n",
"\n",
"dense_output = layers.Dense(units=1, name='dense_layer')(preprocessing_layer)\n",
"\n",
"outputs = {\n",
" 'dense_output': dense_output\n",
"}\n",
"\n",
"# Create and compile the model's topography.\n",
"my_model = create_model(inputs, outputs, learning_rate)\n",
"my_model = create_model(inputs, dense_output, learning_rate)\n",
"\n",
"# To view a PNG of this model's layers, uncomment the call to\n",
"# `tf.keras.utils.plot_model` below. After running this code cell, click\n",
Expand Down Expand Up @@ -413,12 +409,7 @@
"# Concatenate latitude and longitude into a single tensor as input for the Dense layer.\n",
"concatenate_layer = tf.keras.layers.Concatenate()([latitude, longitude])\n",
"\n",
"dense_output = layers.Dense(units=1, name='dense_layer')(concatenate_layer)\n",
"\n",
"# Define an output dictionary we'll send to the model constructor.\n",
"outputs = {\n",
" 'dense_output': dense_output\n",
"}"
"dense_output = layers.Dense(units=1, name='dense_layer')(concatenate_layer)"
]
},
{
Expand All @@ -445,7 +436,7 @@
"epochs = 35\n",
"\n",
"# Build the model.\n",
"my_model = create_model(inputs, outputs, learning_rate)\n",
"my_model = create_model(inputs, dense_output, learning_rate)\n",
"\n",
"# Train the model on the training set.\n",
"epochs, rmse = train_model(my_model, train_df, epochs, batch_size, label_name)\n",
Expand Down Expand Up @@ -574,12 +565,7 @@
" output_mode='one_hot',\n",
" name='cross_latitude_longitude')([latitude, longitude])\n",
"\n",
"dense_output = layers.Dense(units=1, name='dense_layer')(feature_cross)\n",
"\n",
"# Define an output dictionary we'll send to the model constructor.\n",
"outputs = {\n",
" 'dense_output': dense_output\n",
"}"
"dense_output = layers.Dense(units=1, name='dense_layer')(feature_cross)"
]
},
{
Expand All @@ -604,7 +590,7 @@
"epochs = 35\n",
"\n",
"# Build the model, this time passing in the feature_cross_feature_layer:\n",
"my_model = create_model(inputs, outputs, learning_rate)\n",
"my_model = create_model(inputs, dense_output, learning_rate)\n",
"\n",
"# Train the model on the training set.\n",
"epochs, rmse = train_model(my_model, train_df, epochs, batch_size, label_name)\n",
Expand Down Expand Up @@ -695,10 +681,6 @@
],
"metadata": {
"colab": {
"last_runtime": {
"build_target": "//learning/grp/tools/ml_python:ml_notebook",
"kind": "private"
},
"name": "Representation with a Feature Cross.ipynb",
"private_outputs": true,
"provenance": []
Expand All @@ -710,4 +692,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}

0 comments on commit 6a9e1a3

Please sign in to comment.