How to load sparse data with TensorFlow?

后端 未结 5 1423
故里飘歌
故里飘歌 2021-02-12 23:23

There is a small snippet about loading sparse data but I have no idea how to use it.

SparseTensors don\'t play well with queues. If you use SparseTensors

5条回答
  •  伪装坚强ぢ
    2021-02-12 23:50

    You can use weighted_categorical_column to parse index and value, eg.

    categorical_column = tf.feature_column.categorical_column_with_identity(
                key='index', num_buckets=your_feature_dim)
    sparse_columns = tf.feature_column.weighted_categorical_column(
        categorical_column=categorical_column, weight_feature_key='value')
    

    then feed sparse_columns to linear model estimator, before feed to DNN, please use embedding, eg.

    dense_columns = tf.feature_column.embedding_column(sparse_columns, your_embedding_dim)
    

    then feed dense_columns to your DNN estimator

提交回复
热议问题