\n",
"
\n",
" 特徴量カラム | \n",
" Keras レイヤー | \n",
"
\n",
" \n",
" `tf.feature_column.bucketized_column` | \n",
" `tf.keras.layers.Discretization` | \n",
"
\n",
" \n",
" `tf.feature_column.categorical_column_with_hash_bucket` | \n",
" `tf.keras.layers.Hashing` | \n",
"
\n",
" \n",
" `tf.feature_column.categorical_column_with_identity` | \n",
" `tf.keras.layers.CategoryEncoding` | \n",
"
\n",
" \n",
" `tf.feature_column.categorical_column_with_vocabulary_file` | \n",
" `tf.keras.layers.StringLookup` または `tf.keras.layers.IntegerLookup` | \n",
"
\n",
" \n",
" `tf.feature_column.categorical_column_with_vocabulary_list` | \n",
" `tf.keras.layers.StringLookup` または `tf.keras.layers.IntegerLookup` | \n",
"
\n",
" \n",
" `tf.feature_column.crossed_column` | \n",
" `tf.keras.layers.experimental.preprocessing.HashedCrossing` | \n",
"
\n",
" \n",
" `tf.feature_column.embedding_column` | \n",
" `tf.keras.layers.Embedding` | \n",
"
\n",
" \n",
" `tf.feature_column.indicator_column` | \n",
" `output_mode='one_hot'` または `output_mode='multi_hot'`* | \n",
"
\n",
" \n",
" `tf.feature_column.numeric_column` | \n",
" `tf.keras.layers.Normalization` | \n",
"
\n",
" \n",
" `tf.feature_column.sequence_categorical_column_with_hash_bucket` | \n",
" `tf.keras.layers.Hashing` | \n",
"
\n",
" \n",
" `tf.feature_column.sequence_categorical_column_with_identity` | \n",
" `tf.keras.layers.CategoryEncoding` | \n",
"
\n",
" \n",
" `tf.feature_column.sequence_categorical_column_with_vocabulary_file` | \n",
" `tf.keras.layers.StringLookup`、`tf.keras.layers.IntegerLookup`、または `tf.keras.layer.TextVectorization`† | \n",
"
\n",
" \n",
" `tf.feature_column.sequence_categorical_column_with_vocabulary_list` | \n",
" `tf.keras.layers.StringLookup`、`tf.keras.layers.IntegerLookup`、または `tf.keras.layer.TextVectorization`† | \n",
"
\n",
" \n",
" `tf.feature_column.sequence_numeric_column` | \n",
" `tf.keras.layers.Normalization` | \n",
"
\n",
" \n",
" `tf.feature_column.weighted_categorical_column` | \n",
" `tf.keras.layers.CategoryEncoding` | \n",
"
\n",
"\n",
"
\n",
"\n",
"† `tf.keras.layers.TextVectorization` は、自由形式のテキスト入力 (文全体または段落全体など)を直接処理できます。これは、TensorFlow 1 でのカテゴリカルシーケンス処理の 1 対 1 の置き換えではありませんが、アドホックテキスト前処理の便利な置き換えを提供します。\n",
"\n",
"† `tf.keras.layers.TextVectorization` は、自由形式のテキスト入力 (文全体または段落全体など)を直接処理できます。これは、TensorFlow 1 でのカテゴリカルシーケンス処理の 1 対 1 の置き換えではありませんが、アドホックテキスト前処理の便利な置き換えを提供します。\n",
"\n",
"注意: `tf.estimator.LinearClassifier` などの線形 Estimator は、`embedding_column` または `indicator_column` なしで直接のカテゴリカル入力(整数インデックス)を処理できます。ただし、整数インデックスを `tf.keras.layers.Dense` または `tf.keras.experimental.LinearModel` に直接渡すことはできません。これらの入力は、 `Dense` または `LinearModel` を呼び出す前に最初に `tf.layers.CategoryEncoding` で `output_mode='count'`(カテゴリサイズが大きい場合は `sparse=True`)でエンコードする必要があります)。"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "AQCJ6lM3YDq_"
},
"source": [
"## 次のステップ\n",
"\n",
"- Keras 前処理レイヤーの詳細については、[前処理レイヤーの操作](https://www.tensorflow.org/guide/keras/preprocessing_layers)ガイドを参照してください。\n",
"- 前処理レイヤーを構造化データに適用する詳細な例については、[Keras 前処理レイヤーを使用して構造化データを分類する](../../tutorials/structured_data/preprocessing_layers.ipynb)チュートリアルを参照してください。"
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "migrating_feature_columns.ipynb",
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 0
}