Formation of the neural network architecture of the model and downloading its weights to obtain features / scores based on deep features (text modality)
_b5s.text_model_nn_
- Neural network model tf.keras.Model for obtaining features / scores by deep features
Import required packages
[2]:
from oceanai.modules.lab.build import Run
Build
[3]:
_b5 = Run(
lang = 'en', # Inference language
color_simple = '#333', # Plain text color (hexadecimal code)
color_info = '#1776D2', # The color of the text containing the information (hexadecimal code)
color_err = '#FF0000', # Error text color (hexadecimal code)
color_true = '#008001', # Text color containing positive information (hexadecimal code)
bold_text = True, # Bold text
num_to_df_display = 30, # Number of rows to display in tables
text_runtime = 'Runtime', # Runtime text
metadata = True # Displaying information about library
)
[2023-12-10 17:12:11] OCEANAI - personality traits: Authors: Elena Ryumina [ryumina_ev@mail.ru] Dmitry Ryumin [dl_03.03.1991@mail.ru] Alexey Karpov [karpov@iias.spb.su] Maintainers: Elena Ryumina [ryumina_ev@mail.ru] Dmitry Ryumin [dl_03.03.1991@mail.ru] Version: 1.0.0a5 License: BSD License
Formation of the neural network architecture of the model (FI V2
)
[4]:
res_load_text_model_nn_fi = _b5.load_text_model_nn(
corpus = "fi", # Corpus selection for models trained on First Impressions V2 'fi' and models trained on for MuPTA 'mupta'
show_summary = False, # Displaying the formed neural network architecture of the model
out = True, # Display
runtime = True, # Runtime count
run = True # Run blocking
)
[2023-12-10 16:55:40] Formation of a neural network architecture for obtaining scores by deep features (text modality) …
— Runtime: 1.03 sec. —
Downloading the weights of the neural network model
[5]:
# Core settings
_b5.path_to_save_ = './models' # Directory to save the file
_b5.chunk_size_ = 2000000 # File download size from network in 1 step
url = _b5.weights_for_big5_['text']['fi']['nn']['sberdisk']
res_load_text_model_weights_nn_fi = _b5.load_text_model_weights_nn(
url = url, # Full path to the file with weights of the neural network model
force_reload = True, # Forced download of a file with weights of a neural network model from the network
out = True, # Display
runtime = True, # Runtime count
run = True # Run blocking
)
[2023-12-10 16:55:45] Downloading the weights of a neural network model to obtain deep features (text modality) …
[2023-12-10 16:55:45] File download “weights_2023-07-03_15-01-08.h5” 100.0% …
— Runtime: 0.393 sec. —
Displaying the formed neural network architecture of the model
[6]:
_b5.text_model_nn_.summary()
Model: "model"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
model_nn/input (InputLayer) [(None, 104, 768)] 0 []
model_nn/bilstm_1 (Bidirection (None, 104, 64) 205056 ['model_nn/input[0][0]']
al)
model_nn/attention (Attention) (None, 104, 64) 0 ['model_nn/bilstm_1[0][0]',
'model_nn/bilstm_1[0][0]']
model_nn/dence_2 (Dense) (None, 104, 128) 8320 ['model_nn/attention[0][0]']
model_nn/add (Addition) (None, 256) 0 ['model_nn/dence_2[0][0]']
model_nn/dence_3 (Dense) (None, 128) 32896 ['model_nn/add[0][0]']
dense (Dense) (None, 5) 645 ['model_nn/dence_3[0][0]']
==================================================================================================
Total params: 246,917
Trainable params: 246,917
Non-trainable params: 0
__________________________________________________________________________________________________
Formation of the neural network architecture of the model (MuPTA
)
[7]:
res_load_text_model_nn_mupta = _b5.load_text_model_nn(
corpus = "mupta", # Corpus selection for models trained on First Impressions V2 'fi' and models trained on for MuPTA 'mupta'
show_summary = False, # Displaying the formed neural network architecture of the model
out = True, # Display
runtime = True, # Runtime count
run = True # Run blocking
)
[2023-12-10 16:55:49] Formation of the neural network architecture of the model for obtaining scores by deep features (text modality) …
— Runtime: 0.264 sec. —
Downloading the weights of the neural network model
[8]:
# Core settings
_b5.path_to_save_ = './models' # Directory to save the file
_b5.chunk_size_ = 2000000 # File download size from network in 1 step
url = _b5.weights_for_big5_['text']['mupta']['nn']['sberdisk']
res_load_text_model_weights_nn_mupta = _b5.load_text_model_weights_nn(
url = url, # Full path to the file with weights of the neural network model
force_reload = True, # Forced download of a file with weights of a neural network model from the network
out = True, # Display
runtime = True, # Runtime count
run = True # Run blocking
)
[2023-12-10 16:55:51] Downloading the weights of a neural network model to obtain deep features (text modality) …
[2023-12-10 16:55:52] File download “weights_2023-07-16_18-12-01.h5” 100.0% …
— Runtime: 0.373 sec. —
Displaying the formed neural network architecture of the model
[9]:
_b5.text_model_nn_.summary()
Model: "model_1"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
model_nn/input (InputLayer) [(None, 414, 768)] 0 []
model_nn/bilstm_1 (Bidirection (None, 414, 64) 205056 ['model_nn/input[0][0]']
al)
model_nn/attention (Attention) (None, 414, 64) 0 ['model_nn/bilstm_1[0][0]',
'model_nn/bilstm_1[0][0]']
model_nn/dence_2 (Dense) (None, 414, 128) 8320 ['model_nn/attention[0][0]']
model_nn/add (Addition) (None, 256) 0 ['model_nn/dence_2[0][0]']
model_nn/dence_3 (Dense) (None, 128) 32896 ['model_nn/add[0][0]']
dense_1 (Dense) (None, 5) 645 ['model_nn/dence_3[0][0]']
==================================================================================================
Total params: 246,917
Trainable params: 246,917
Non-trainable params: 0
__________________________________________________________________________________________________