Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17011

Working with preprocessing layers in Keras

$
0
0

I am trying to build a layer that autonomously handles the preprocessing of categorical features of type string, I started by constructing the following function:

def encodingLayer(features):lookup = tf.keras.layers.StringLookup(output_mode = "int",                                      max_tokens = None,                                      vocabulary = None)lookup.adapt(features)return(lookup.get_vocabulary())

and I get the following output:

encodingLayer(df)['[UNK]','food','serious','not serious','nuts, nut products and seeds','fruits and vegetables',...]

How can I integrate the tf.keras.layers.CategoryEncoding() function at this point to get a one-hot encoding?Any suggestions?


Viewing all articles
Browse latest Browse all 17011

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>