Loading...
Searching...
No Matches
opennn::TextClassificationNetwork Class Reference

#include <opennn/models/models.h>

Inheritance diagram for opennn::TextClassificationNetwork:
opennn::Network

Classes

struct  Prediction
 

Public Member Functions

 TextClassificationNetwork (const Shape &, const Shape &, const Shape &, PoolingMethod pooling_method=PoolingMethod::AveragePooling)
 
Prediction classify (string_view)
 
MatrixR calculate_text_outputs (const Tensor< string, 1 > &)
 
void set_tokenizer (unique_ptr< TokenizerOperator >)
 
const TokenizerOperator * get_tokenizer () const
 
- Public Member Functions inherited from opennn::Network
 Network ()
 
virtual ~Network ()=default
 
 Network (const filesystem::path &)
 
NetworkTask get_task () const noexcept
 
void set_task (NetworkTask new_task) noexcept
 
Index add_layer (unique_ptr< Layer >, const vector< Index > &={})
 
const EffectiveConfig & get_config () const noexcept
 
Device get_device () const noexcept
 
bool is_gpu () const noexcept
 
Type get_training_type () const noexcept
 
const PrecisionPlan & get_precision () const noexcept
 
Type get_activation_type () const noexcept
 
void set_training_activation_recomputation (bool enabled) noexcept
 
bool get_training_activation_recomputation () const noexcept
 
void warn_if_stale_configuration () const
 
vector< vector< TensorSpec > > get_parameter_specs () const
 
vector< vector< TensorSpec > > get_state_specs () const
 
vector< vector< TensorSpec > > get_forward_specs (Index batch_size) const
 
vector< vector< TensorSpec > > get_backward_specs (Index batch_size) const
 
Index get_states_size () const
 
void compile ()
 
void compile (Device device)
 
void set_attention_sdpa_auto (bool)
 
void set_attention_sdpa_min_sequence_length (Index)
 
bool has (const string &) const
 
bool has (LayerType) const
 
bool has_recurrent_layers () const
 
bool is_empty () const noexcept
 
uint64_t get_parameters_version () const noexcept
 
void mark_parameters_changed () noexcept
 
float * get_parameters_data ()
 
const float * get_parameters_data () const
 
VectorMap get_parameters_map () &
 
ConstVectorMap get_parameters_map () const &
 
Index get_parameters_buffer_size () const noexcept
 
Device get_parameters_device () const noexcept
 
float * get_states_data ()
 
const float * get_states_data () const
 
Index get_states_buffer_size () const noexcept
 
const vector< Variable > & get_input_variables () const noexcept
 
vector< string > get_input_feature_names () const
 
const vector< Variable > & get_output_variables () const noexcept
 
vector< string > get_output_feature_names () const
 
const vector< unique_ptr< Layer > > & get_layers () const noexcept
 
const unique_ptr< Layer > & get_layer (const Index layer_index) const
 
const unique_ptr< Layer > & get_layer (const string &) const
 
Index get_layer_index (const string &) const
 
const vector< vector< Index > > & get_source_layers () const noexcept
 
vector< vector< pair< size_t, size_t > > > get_consumer_edges () const
 
Layer * get_first (const string &)
 
Layer * get_first (LayerType)
 
const Layer * get_first (const string &) const
 
const Layer * get_first (LayerType) const
 
void set_input_variables (const vector< Variable > &new_input_variables)
 
void set_output_variables (const vector< Variable > &new_output_variables)
 
void set_input_names (const vector< string > &)
 
void set_output_names (const vector< string > &)
 
void set_input_shape (const Shape &)
 
void clear ()
 
void steal_from (Network &src)
 
Index get_layers_number () const noexcept
 
Index get_layers_number (const string &) const
 
Index get_layers_number (LayerType) const
 
Index get_first_trainable_layer_index () const
 
Index get_last_trainable_layer_index () const
 
Index get_inputs_number () const
 
Index get_outputs_number () const
 
Shape get_input_shape () const
 
Shape get_output_shape () const
 
ActivationFunction get_output_activation () const
 
Index get_parameters_number () const
 
void set_parameters (const VectorR &)
 
void set_states (const VectorR &)
 
void set_parameters_random ()
 
void set_parameters_glorot ()
 
void set_parameters_pytorch ()
 
void link_parameters ()
 
ParameterStorage get_parameter_storage () const noexcept
 
bool fp32_master_released () const noexcept
 
bool low_precision_storage_ready () const noexcept
 
void link_gradients (const Buffer &) const
 
void link_gradients (span< const TensorView > layer_gradients) const
 
void link_states ()
 
void link_states (Device)
 
MatrixR calculate_outputs (const vector< TensorView > &)
 
void calculate_outputs (const vector< TensorView > &, MatrixR &outputs)
 
TensorView calculate_outputs_resident (const vector< TensorView > &, ForwardPropagation &, bool upload_parameters=true)
 
MatrixR calculate_outputs (const MatrixR &)
 
MatrixR calculate_outputs (const Tensor3 &)
 
MatrixR calculate_outputs (const Tensor4 &)
 
MatrixR calculate_text_outputs (const Tensor< string, 1 > &)
 
void set_tokenizer (unique_ptr< TokenizerOperator >, const string &label="tokenizer")
 
const TokenizerOperator * get_tokenizer (const string &label="tokenizer") const
 
void set_vocabulary (const vector< string > &, const string &label="tokenizer")
 
const vector< string > & get_vocabulary (const string &label="tokenizer") const
 
void calculate_outputs (const MatrixR &, MatrixR &outputs)
 
void calculate_outputs (const Tensor3 &, MatrixR &outputs)
 
void calculate_outputs (const Tensor4 &, MatrixR &outputs)
 
Tensor3 calculate_outputs (const Tensor3 &, const Tensor3 &)
 
void calculate_outputs (const Tensor3 &, const Tensor3 &, Tensor3 &outputs)
 
void from_JSON (const JsonDocument &)
 
void to_JSON (JsonWriter &) const
 
void save (const filesystem::path &) const
 
void save_parameters_binary (const filesystem::path &) const
 
void save_states_binary (const filesystem::path &) const
 
void load (const filesystem::path &)
 
void load_parameters_binary (const filesystem::path &)
 
void load_parameters_bf16_inference_binary (const filesystem::path &)
 
void load_states_binary (const filesystem::path &)
 
void forward_propagate (const vector< TensorView > &, ForwardPropagation &, ForwardPropagationMode=ForwardPropagationMode::Inference) const
 
void forward_propagate (const vector< TensorView > &, ForwardPropagation &, ForwardPropagationMode, Index, Index) const
 
void forward_propagate (const vector< TensorView > &, const VectorR &, ForwardPropagation &)
 
void cast_parameters_to_bf16 ()
 
void release_bf16_fp32_parameter_master_for_inference ()
 
void upload_parameters_bf16_inference ()
 
void upload_parameters_int8_inference ()
 
bfloat16 * get_parameters_bf16_mirror_data ()
 
void copy_parameters_device ()
 
void copy_parameters_host ()
 
void copy_states_device ()
 
void copy_states_host ()
 
vector< string > get_layer_labels () const
 

Static Public Attributes

static constexpr Index default_embedding_dimension = 64
 
static constexpr Index default_heads_number = 4
 
static constexpr Index default_hidden_neurons = 64
 

Additional Inherited Members

- Public Types inherited from opennn::Network
enum class  ParameterStorage { Host , DeviceMaster , DeviceMasterWithMirror , DeviceCompact }
 
- Protected Member Functions inherited from opennn::Network
 Network (NetworkTask)
 
 Network (const filesystem::path &, NetworkTask)
 
void finalize_build ()
 
void configure_layers (const function< void(Layer &)> &)
 
void set_attention_and_dense_dropout (float, initializer_list< string_view > dense_prefixes)
 
void compile_and_load_parameters_bf16_inference_binary (const filesystem::path &)
 
DeviceResidency get_device_residency () const noexcept
 
- Protected Attributes inherited from opennn::Network
NetworkTask task = NetworkTask::Generic
 
vector< Variable > input_variables
 
vector< Variable > output_variables
 
vector< unique_ptr< Layer > > layers
 
vector< vector< Index > > source_layers
 
uint64_t parameters_version = 1
 
detail::ParameterStore parameter_store
 
Buffer states
 
EffectiveConfig config
 
PrecisionPlan precision
 
bool training_activation_recomputation = false
 
bool stale_configuration_warned = false
 
const void * linked_gradient_base = nullptr
 

Constructor & Destructor Documentation

◆ TextClassificationNetwork()

opennn::TextClassificationNetwork::TextClassificationNetwork ( const Shape & ,
const Shape & ,
const Shape & ,
PoolingMethod pooling_method = PoolingMethod::AveragePooling )

Member Function Documentation

◆ calculate_text_outputs()

MatrixR opennn::TextClassificationNetwork::calculate_text_outputs ( const Tensor< string, 1 > & )

◆ classify()

Prediction opennn::TextClassificationNetwork::classify ( string_view )

◆ get_tokenizer()

const TokenizerOperator * opennn::TextClassificationNetwork::get_tokenizer ( ) const

◆ set_tokenizer()

void opennn::TextClassificationNetwork::set_tokenizer ( unique_ptr< TokenizerOperator > )

Member Data Documentation

◆ default_embedding_dimension

Index opennn::TextClassificationNetwork::default_embedding_dimension = 64
staticconstexpr

◆ default_heads_number

Index opennn::TextClassificationNetwork::default_heads_number = 4
staticconstexpr

◆ default_hidden_neurons

Index opennn::TextClassificationNetwork::default_hidden_neurons = 64
staticconstexpr