Data phrase. More...
#include <xmmPhrase.hpp>
Public Member Functions | |
Phrase (MemoryMode memoryMode=MemoryMode::OwnMemory, Multimodality multimodality=Multimodality::Unimodal) | |
Constructor. More... | |
Phrase (Phrase const &src) | |
Copy Constructor. More... | |
Phrase (Json::Value const &root) | |
Constructor from Json Structure. More... | |
Phrase & | operator= (Phrase const &src) |
Assignment. More... | |
virtual | ~Phrase () |
Destructor. More... | |
Accessors | |
bool | ownMemory () const |
checks if the training set is owns the data More... | |
bool | bimodal () const |
checks if the training set is bimodal More... | |
Access Data | |
unsigned int | size () const |
get the number of frames in the phrase More... | |
unsigned int | inputSize () const |
get the number of frames in the input array of the phrase More... | |
unsigned int | outputSize () const |
get the number of frames in the output array of the phrase More... | |
bool | empty () const |
check if the phrase is empty More... | |
float | getValue (unsigned int index, unsigned int dim) const |
Access data at a given time index and dimension. More... | |
float * | getPointer (unsigned int index) const |
Get pointer to the data at a given time index. More... | |
float * | getPointer_input (unsigned int index) const |
Get pointer to the data at a given time index for the input modality. More... | |
float * | getPointer_output (unsigned int index) const |
Get pointer to the data at a given time index for the output modality. More... | |
Connect (MemoryMode = SharedData) | |
void | connect (float *pointer_to_data, unsigned int length) |
Connect a unimodal phrase to a shared container. More... | |
void | connect (float *pointer_to_data_input, float *pointer_to_data_output, unsigned int length) |
Connect a Bimodal phrase to a shared container. More... | |
void | connect_input (float *pointer_to_data, unsigned int length) |
Connect a Bimodal phrase to a shared container for the input modality. More... | |
void | connect_output (float *pointer_to_data, unsigned int length) |
Connect a Bimodal phrase to a shared container for the output modality. More... | |
void | disconnect () |
Disconnect a phrase from a shared container. More... | |
Record (MemoryMode = OwnData) | |
void | record (std::vector< float > const &observation) |
Record observation. More... | |
void | record_input (std::vector< float > const &observation) |
Record observation on input modality Appends the observation vector observation to the data array This method is only usable in Own Memory (construction with MemoryMode::OwnMemory) More... | |
void | record_output (std::vector< float > const &observation) |
Record observation on output modality Appends the observation vector observation to the data array This method is only usable in Own Memory (construction with MemoryMode::OwnMemory) More... | |
void | clear () |
Reset length of the phrase to 0 ==> empty phrase This method is only usable in Own Memory (construction with MemoryMode::OwnMemory) More... | |
void | clearInput () |
void | clearOutput () |
JSON I/O | |
Json::Value | toJson () const |
Write the object to a JSON Structure. More... | |
void | fromJson (Json::Value const &root) |
Read the object from a JSON Structure. More... | |
Utilities | |
std::vector< float > | mean () const |
Compute the mean of the data phrase along the time axis. More... | |
std::vector< float > | standardDeviation () const |
Compute the standard deviation of the data phrase along the time axis. More... | |
std::vector< std::pair< float, float > > | minmax () const |
Compute the global min/max of the data phrase along the time axis. More... | |
void | rescale (std::vector< float > offset, std::vector< float > gain) |
rescale a phrase given an offset and gain More... | |
Python File I/O | |
void | writeFile (char *fileName) const |
write method for python wrapping ('write' keyword forbidden, name has to be different) More... | |
void | readFile (char *fileName) |
read method for python wrapping ('read' keyword forbidden, name has to be different) More... | |
std::string | __str__ () const |
"print" method for python => returns the results of write method More... | |
Public Attributes | |
Attribute< unsigned int > | dimension |
Total dimension of the phrase. More... | |
Attribute< unsigned int > | dimension_input |
Used in bimodal mode: dimension of the input modality. More... | |
Attribute< std::string > | label |
Main label of the phrase. More... | |
std::vector< std::string > | column_names |
labels of the columns of the phrase (e.g. descriptor names) More... | |
Protected Member Functions | |
void | trim () |
trim phrase to minimal length of modalities More... | |
void | reallocateLength () |
Memory Allocation. More... | |
virtual void | onAttributeChange (AttributeBase *attr_pointer) |
notification function called when a member attribute is changed More... | |
Protected Attributes | |
bool | own_memory_ |
Defines if the phrase stores the data itself. More... | |
bool | bimodal_ |
Defines if the phrase is bimodal (true) or unimodal (false) More... | |
bool | empty_ |
true if the phrase does not contain any data More... | |
unsigned int | length_ |
Length of the phrase. If bimodal, it is the minimal length between modalities. More... | |
unsigned int | input_length_ |
Length of the array of the input modality. More... | |
unsigned int | output_length_ |
Length of the array of the output modality. More... | |
unsigned int | max_length_ |
Allocated length (only used in own memory mode) More... | |
float ** | data_ |
Pointer to the Data arrays. More... | |
EventGenerator< PhraseEvent > | events |
Static Protected Attributes | |
static const unsigned int | AllocationBlockSize = 256 |
Friends | |
class | TrainingSet |
Data phrase.
The Phrase class can be used to store unimodal and Bimodal data phrases. It can have an autonomous memory, or this memory can be shared with another data container. These attributes are specified at construction.
xmm::Phrase::Phrase | ( | MemoryMode | memoryMode = MemoryMode::OwnMemory , |
Multimodality | multimodality = Multimodality::Unimodal |
||
) |
Constructor.
memoryMode | Memory mode (owned vs shared) |
multimodality | Number of modalities |
xmm::Phrase::Phrase | ( | Phrase const & | src | ) |
Copy Constructor.
src | source Phrase |
|
explicit |
Constructor from Json Structure.
root | Json Value |
|
virtual |
Destructor.
Data is only deleted if the memory is owned (construction with MemoryMode::OwnMemory)
|
inlineinherited |
"print" method for python => returns the results of write method
bool xmm::Phrase::bimodal | ( | ) | const |
checks if the training set is bimodal
void xmm::Phrase::clear | ( | ) |
Reset length of the phrase to 0 ==> empty phrase
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory)
runtime_error | if data is shared (construction with MemoryMode::SharedMemory flag) |
void xmm::Phrase::clearInput | ( | ) |
void xmm::Phrase::clearOutput | ( | ) |
void xmm::Phrase::connect | ( | float * | pointer_to_data, |
unsigned int | length | ||
) |
Connect a unimodal phrase to a shared container.
pointer_to_data | pointer to the data array |
length | length of the data array |
runtime_error | if data is owned (construction with MemoryMode::OwnMemory flag) |
void xmm::Phrase::connect | ( | float * | pointer_to_data_input, |
float * | pointer_to_data_output, | ||
unsigned int | length | ||
) |
Connect a Bimodal phrase to a shared container.
pointer_to_data_input | pointer to the data array of the input modality |
pointer_to_data_output | pointer to the data array of the output modality |
length | length of the data array |
runtime_error | if data is owned (construction with MemoryMode::OwnMemory flag) |
void xmm::Phrase::connect_input | ( | float * | pointer_to_data, |
unsigned int | length | ||
) |
Connect a Bimodal phrase to a shared container for the input modality.
pointer_to_data | pointer to the data array of the input modality |
length | length of the data array |
runtime_error | if data is owned (construction with MemoryMode::OwnMemory flag) |
void xmm::Phrase::connect_output | ( | float * | pointer_to_data, |
unsigned int | length | ||
) |
Connect a Bimodal phrase to a shared container for the output modality.
pointer_to_data | pointer to the data array of the output modality |
length | length of the data array |
runtime_error | if data is owned (construction with MemoryMode::OwnMemory flag) |
void xmm::Phrase::disconnect | ( | ) |
Disconnect a phrase from a shared container.
runtime_error | if data is owned (construction with MemoryMode::OwnMemory flag) |
bool xmm::Phrase::empty | ( | ) | const |
check if the phrase is empty
|
virtual |
Read the object from a JSON Structure.
root | JSON value containing the object's information |
JsonException | if the JSON value has a wrong format |
Implements xmm::Writable.
float * xmm::Phrase::getPointer | ( | unsigned int | index | ) | const |
Get pointer to the data at a given time index.
index | time index |
out_of_range | if time index is out of bounds |
runtime_error | if the phrase is bimodal (construction with Multimodality::Bimodal) |
float * xmm::Phrase::getPointer_input | ( | unsigned int | index | ) | const |
Get pointer to the data at a given time index for the input modality.
index | time index |
out_of_range | if time index is out of bounds |
runtime_error | if the phrase is unimodal (construction with Multimodality::Unimodal) |
float * xmm::Phrase::getPointer_output | ( | unsigned int | index | ) | const |
Get pointer to the data at a given time index for the output modality.
index | time index |
out_of_range | if time index is out of bounds |
runtime_error | if the phrase is unimodal (construction with Multimodality::Unimodal) |
float xmm::Phrase::getValue | ( | unsigned int | index, |
unsigned int | dim | ||
) | const |
Access data at a given time index and dimension.
index | time index |
dim | dimension considered, indexed from 0 to the total dimension of the data across modalities |
out_of_range | if time index or dimension are out of bounds |
unsigned int xmm::Phrase::inputSize | ( | ) | const |
get the number of frames in the input array of the phrase
std::vector< float > xmm::Phrase::mean | ( | ) | const |
Compute the mean of the data phrase along the time axis.
std::vector< std::pair< float, float > > xmm::Phrase::minmax | ( | ) | const |
Compute the global min/max of the data phrase along the time axis.
|
protectedvirtual |
notification function called when a member attribute is changed
xmm::Phrase & xmm::Phrase::operator= | ( | Phrase const & | src | ) |
Assignment.
src | source Phrase |
unsigned int xmm::Phrase::outputSize | ( | ) | const |
get the number of frames in the output array of the phrase
bool xmm::Phrase::ownMemory | ( | ) | const |
checks if the training set is owns the data
|
inlineinherited |
read method for python wrapping ('read' keyword forbidden, name has to be different)
|
protected |
Memory Allocation.
used record mode (no SHARED_MEMORY flag), the data vector is reallocated with a block size ALLOC_BLOCKSIZE
void xmm::Phrase::record | ( | std::vector< float > const & | observation | ) |
Record observation.
Appends the observation vector observation to the data array.
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory)
observation | observation vector (C-like array which must have the size of the total dimension of the data across all modalities) |
runtime_error | if data is shared (construction with MemoryMode::SharedMemory flag) |
void xmm::Phrase::record_input | ( | std::vector< float > const & | observation | ) |
Record observation on input modality Appends the observation vector observation to the data array
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory)
observation | observation vector (C-like array which must have the size of the total dimension of the data across all modalities) |
runtime_error | if data is shared (construction with MemoryMode::SharedMemory flag) |
void xmm::Phrase::record_output | ( | std::vector< float > const & | observation | ) |
Record observation on output modality Appends the observation vector observation to the data array
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory)
observation | observation vector (C-like array which must have the size of the total dimension of the data across all modalities) |
runtime_error | if data is shared (construction with MemoryMode::SharedMemory flag) |
void xmm::Phrase::rescale | ( | std::vector< float > | offset, |
std::vector< float > | gain | ||
) |
rescale a phrase given an offset and gain
offset | constant offset to be subtracted |
gain | gain to be applied |
unsigned int xmm::Phrase::size | ( | ) | const |
get the number of frames in the phrase
std::vector< float > xmm::Phrase::standardDeviation | ( | ) | const |
Compute the standard deviation of the data phrase along the time axis.
|
virtual |
Write the object to a JSON Structure.
Implements xmm::Writable.
|
protected |
trim phrase to minimal length of modalities
|
inlineinherited |
write method for python wrapping ('write' keyword forbidden, name has to be different)
|
friend |
|
staticprotected |
|
protected |
Defines if the phrase is bimodal (true) or unimodal (false)
std::vector<std::string> xmm::Phrase::column_names |
labels of the columns of the phrase (e.g. descriptor names)
|
protected |
Pointer to the Data arrays.
data has a size 1 in unimodal mode, 2 in bimodal mode.
Attribute<unsigned int> xmm::Phrase::dimension |
Total dimension of the phrase.
Attribute<unsigned int> xmm::Phrase::dimension_input |
Used in bimodal mode: dimension of the input modality.
|
protected |
true if the phrase does not contain any data
|
protected |
|
protected |
Length of the array of the input modality.
Attribute<std::string> xmm::Phrase::label |
Main label of the phrase.
|
protected |
Length of the phrase. If bimodal, it is the minimal length between modalities.
|
protected |
Allocated length (only used in own memory mode)
|
protected |
Length of the array of the output modality.
|
protected |
Defines if the phrase stores the data itself.