--- license: mit datasets: - databoyface/python-tf-ome-src-v4.1 language: - en --- # Orthogonal Model of Emotions A Text Classifier created using TensorFlow and Keras ## Author C.J. Pitchford ## Published 18 August 2025 ## Model and Weights Model: "sequential" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= embedding (Embedding) (None, 1000, 64) 6400000 bidirectional (Bidirection (None, 1000, 128) 66048 al) global_max_pooling1d (Glob (None, 128) 0 alMaxPooling1D) dense (Dense) (None, 64) 8256 dropout (Dropout) (None, 64) 0 dense_1 (Dense) (None, 47) 3055 ================================================================= Total params: 6477359 (24.71 MB) Trainable params: 6477359 (24.71 MB) Non-trainable params: 0 (0.00 Byte) ## Usage import numpy as np import tensorflow as tf import tensorflow.keras.preprocessing.text as text import pickle from tensorflow.keras.preprocessing.sequence import pad_sequences # 1. Load pre-trained model model = tf.keras.models.load_model('OME4tf/ome-4a-model.h5') # 2. Load tokenizer and label encoder with open('OME4tf/ome-4a-tokenizer.pkl', 'rb') as f: tokenizer = pickle.load(f) with open('OME4tf/ome-4a-label_encoder.pkl', 'rb') as f: label_encoder = pickle.load(f) # 3. Test model with prediction on text "I failed to hide my distress." text = "I failed to hide my distress." text_seq = tokenizer.texts_to_sequences([text]) max_len = 1000 text_seq = pad_sequences(text_seq, maxlen=max_len, padding='post') pred_probs = model.predict(text_seq) pred_label = np.argmax(pred_probs, axis=1) print(f"Statement: {text}\nPrediction: {label_encoder.classes_[pred_label][0]}") ## Additional Tokenizer and label encoder included as JSON to avoid using `pickle` files.