View source on GitHub |
A specification of averaging word vector model.
tflite_model_maker.text_classifier.AverageWordVecSpec(
num_words=10000,
seq_len=256,
wordvec_dim=16,
lowercase=True,
dropout_rate=0.2,
name='AverageWordVec',
default_training_epochs=2,
default_batch_size=32,
model_dir=None,
index_to_label=None
)
Used in the notebooks
Used in the tutorials |
---|
Methods
convert_examples_to_features
convert_examples_to_features(
examples, tfrecord_file, label_names
)
Converts examples to features and write them into TFRecord file.
create_model
create_model(
num_classes, optimizer='rmsprop', with_loss_and_metrics=True
)
Creates the keras model.
gen_vocab
gen_vocab(
examples
)
Generates vocabulary list in examples
with maximum num_words
words.
get_config
get_config()
Gets the configuration.
get_default_quantization_config
get_default_quantization_config()
Gets the default quantization configuration.
get_name_to_features
get_name_to_features()
Gets the dictionary describing the features.
load_vocab
load_vocab(
vocab_filename
)
Loads vocabulary from vocab_filename
.
preprocess
preprocess(
raw_text
)
Preprocess the text for text classification.
run_classifier
run_classifier(
train_ds, validation_ds, epochs, steps_per_epoch, num_classes, **kwargs
)
Creates classifier and runs the classifier training.
save_vocab
save_vocab(
vocab_filename
)
Saves the vocabulary in vocab_filename
.
select_data_from_record
select_data_from_record(
record
)
Dispatches records to features and labels.
Class Variables | |
---|---|
PAD |
'<PAD>'
|
START |
'<START>'
|
UNKNOWN |
'<UNKNOWN>'
|
compat_tf_versions |
[2]
|
convert_from_saved_model_tf2 |
False
|
need_gen_vocab |
True
|