Coder Social home page Coder Social logo

tf.keras.layers.DenseFeatures api as the candidate of hb.feature_column.DenseFeatures can not work with tf.feature_column.shared_embedding_columns about hybridbackend HOT 1 CLOSED

taoyun951753 avatar taoyun951753 commented on June 15, 2024
tf.keras.layers.DenseFeatures api as the candidate of hb.feature_column.DenseFeatures can not work with tf.feature_column.shared_embedding_columns

from hybridbackend.

Comments (1)

francktcheng avatar francktcheng commented on June 15, 2024

We recommend you to use the tf.feature_column.input_layer instead of tf.keras.layers.DenseFeatures when the feature columns are generated by using tf.feature_column.shared_embedding_columns. Please refer to the code example as follows:

...
self._embedding_columns = tf.feature_column.shared_embedding_columns(
        [tf.feature_column.categorical_column_with_identity(
          key=f,
          num_buckets=self._args.data_spec.embedding_sizes[f],
          default_value=self._args.data_spec.defaults[f])
          for f in self._categorical_fields],
        dimension=self._args.embedding_dim,
        initializer=tf.random_uniform_initializer(-1e-3, 1e-3)
      )
cols_to_output_tensors = {}
      tf.feature_column.input_layer(
        {f: features[f] for f in self._categorical_fields},
        self._embedding_columns,
        cols_to_output_tensors=cols_to_output_tensors)
 ...

Internally, the tf.feature_column.input_layer API does accept feature columns with a type of _FeatureColumn while the API of tf.keras.layers.DenseFeatures only accepts a type derived from FeatureColumn which is not compatible with that of a shared embedding.

from hybridbackend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.