Skip to content

Commit 64e7a68

Browse files
committed
debug
1 parent 5f3d273 commit 64e7a68

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

Diff for: site/en/tutorials/structured_data/preprocessing_layers.ipynb

+21-10
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@
447447
"source": [
448448
"### Categorical columns\n",
449449
"\n",
450-
"Pet `Type`s in the dataset are represented as strings—`Dog`s and `Cat`s—which need to be multi-hot encoded before being fed into the model. The `Age` feature \n",
450+
"Pet `Type`s in the dataset are represented as strings—`Dog`s and `Cat`s—which need to be multi-hot encoded before being fed into the model. The `Age` feature\n",
451451
"\n",
452452
"Define another new utility function that returns a layer which maps values from a vocabulary to integer indices and multi-hot encodes the features using the `tf.keras.layers.StringLookup`, `tf.keras.layers.IntegerLookup`, and `tf.keras.CategoryEncoding` preprocessing layers:"
453453
]
@@ -589,15 +589,15 @@
589589
},
590590
"outputs": [],
591591
"source": [
592-
"all_inputs = []\n",
592+
"all_inputs = {}\n",
593593
"encoded_features = []\n",
594594
"\n",
595595
"# Numerical features.\n",
596596
"for header in ['PhotoAmt', 'Fee']:\n",
597597
" numeric_col = tf.keras.Input(shape=(1,), name=header)\n",
598598
" normalization_layer = get_normalization_layer(header, train_ds)\n",
599599
" encoded_numeric_col = normalization_layer(numeric_col)\n",
600-
" all_inputs.append(numeric_col)\n",
600+
" all_inputs[header] = numeric_col\n",
601601
" encoded_features.append(encoded_numeric_col)"
602602
]
603603
},
@@ -625,7 +625,7 @@
625625
" dtype='int64',\n",
626626
" max_tokens=5)\n",
627627
"encoded_age_col = encoding_layer(age_col)\n",
628-
"all_inputs.append(age_col)\n",
628+
"all_inputs['Age'] = age_col\n",
629629
"encoded_features.append(encoded_age_col)"
630630
]
631631
},
@@ -656,7 +656,7 @@
656656
" dtype='string',\n",
657657
" max_tokens=5)\n",
658658
" encoded_categorical_col = encoding_layer(categorical_col)\n",
659-
" all_inputs.append(categorical_col)\n",
659+
" all_inputs[header] = categorical_col\n",
660660
" encoded_features.append(encoded_categorical_col)"
661661
]
662662
},
@@ -678,6 +678,17 @@
678678
"The next step is to create a model using the [Keras Functional API](https://www.tensorflow.org/guide/keras/functional). For the first layer in your model, merge the list of feature inputs—`encoded_features`—into one vector via concatenation with `tf.keras.layers.concatenate`."
679679
]
680680
},
681+
{
682+
"cell_type": "code",
683+
"execution_count": null,
684+
"metadata": {
685+
"id": "EtkwHC-akvcv"
686+
},
687+
"outputs": [],
688+
"source": [
689+
"encoded_features"
690+
]
691+
},
681692
{
682693
"cell_type": "code",
683694
"execution_count": null,
@@ -713,7 +724,8 @@
713724
"source": [
714725
"model.compile(optimizer='adam',\n",
715726
" loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),\n",
716-
" metrics=[\"accuracy\"])"
727+
" metrics=[\"accuracy\"],\n",
728+
" run_eagerly=True)"
717729
]
718730
},
719731
{
@@ -734,7 +746,7 @@
734746
"outputs": [],
735747
"source": [
736748
"# Use `rankdir='LR'` to make the graph horizontal.\n",
737-
"tf.keras.utils.plot_model(model, show_shapes=True, rankdir=\"LR\")"
749+
"tf.keras.utils.plot_model(model, show_shapes=True, show_layer_names=True, rankdir=\"LR\")"
738750
]
739751
},
740752
{
@@ -765,8 +777,8 @@
765777
},
766778
"outputs": [],
767779
"source": [
768-
"loss, accuracy = model.evaluate(test_ds)\n",
769-
"print(\"Accuracy\", accuracy)"
780+
"result = model.evaluate(test_ds, return_dict=True)\n",
781+
"print(result)"
770782
]
771783
},
772784
{
@@ -869,7 +881,6 @@
869881
],
870882
"metadata": {
871883
"colab": {
872-
"collapsed_sections": [],
873884
"name": "preprocessing_layers.ipynb",
874885
"toc_visible": true
875886
},

0 commit comments

Comments
 (0)