SciSharp / TensorFlow.NET

.NET Standard bindings for Google's TensorFlow for developing, training and deploying Machine Learning models in C# and F#.
https://scisharp.github.io/tensorflow-net-docs
Apache License 2.0
3.17k stars 506 forks source link

[Question]: Can now work the TextVectorization method? #1261

Open Kyokanyou opened 4 days ago

Kyokanyou commented 4 days ago

Description

I just used this method to creat words vector. var text_dataset = tf.constant( "quz foo tak"); print(text_dataset); var vectorizer = KerasApi.keras.preprocessing.TextVectorization(max_tokens: 1000, output_sequence_length: 4) ; vectorizer.adapt(text_dataset); print(vectorizer.Apply(tf.constant("quz" )));

The result is tf.Tensor: shape=(), dtype=string, numpy='quz foo tak' tf.Tensor: shape=(), dtype=string, numpy='quz'

It seems nothing hanppen. There is also no examples or test code in docs. Please help me the right way to use this method, thanks.

I just checked the decompiled code, I found some things maybe the bugs that in CombinerPreprocessingLayer : Layer this class, the method adapt is virtual modifier. But this class inherits from the abstract class Layer. So the vectorizer.adapt(text_dataset) in my code executed the adapt method in the abstract class Layer, as a result this code vectorizer.adapt(text_dataset) didn't work or just did nothing. There is no connection between the adapt method in
TextVectorization class and ILayer class I guessed that.

I don't know. I'm not good at check the code. I had a headache. But I want to get help even just for learning code.

Alternatives

No response