36 #include "../common/xmmAttribute.hpp" 37 #include "../common/xmmEvents.hpp" 38 #include "../common/xmmJson.hpp" 155 explicit Phrase(Json::Value
const& root);
178 bool ownMemory()
const;
185 bool bimodal()
const;
196 unsigned int size()
const;
202 unsigned int inputSize()
const;
208 unsigned int outputSize()
const;
223 float getValue(
unsigned int index,
unsigned int dim)
const;
235 float* getPointer(
unsigned int index)
const;
247 float* getPointer_input(
unsigned int index)
const;
260 float* getPointer_output(
unsigned int index)
const;
276 void connect(
float* pointer_to_data,
unsigned int length);
290 void connect(
float* pointer_to_data_input,
float* pointer_to_data_output,
291 unsigned int length);
303 void connect_input(
float* pointer_to_data,
unsigned int length);
315 void connect_output(
float* pointer_to_data,
unsigned int length);
342 void record(std::vector<float>
const& observation);
355 void record_input(std::vector<float>
const& observation);
368 void record_output(std::vector<float>
const& observation);
391 Json::Value toJson()
const;
398 void fromJson(Json::Value
const& root);
409 std::vector<float> mean()
const;
416 std::vector<float> standardDeviation()
const;
422 std::vector<std::pair<float, float>> minmax()
const;
429 void rescale(std::vector<float> offset, std::vector<float> gain);
465 void reallocateLength();
472 static const unsigned int AllocationBlockSize = 256;
526 template <
typename T>
527 T*
reallocate(T* src,
unsigned int dim_src,
unsigned int dim_dst) {
528 T* dst =
new T[dim_dst];
530 if (!src)
return dst;
532 if (dim_dst > dim_src) {
533 std::copy(src, src + dim_src, dst);
535 std::copy(src, src + dim_dst, dst);
Data phrase.
Definition: xmmPhrase.hpp:133
Multimodality
Number of modalities in the data phrase.
Definition: xmmPhrase.hpp:68
EventGenerator< PhraseEvent > events
Definition: xmmPhrase.hpp:516
unsigned int output_length_
Length of the array of the output modality.
Definition: xmmPhrase.hpp:503
Attribute< std::string > label
Main label of the phrase.
Definition: xmmPhrase.hpp:446
PhraseEvent(Phrase *phrase_, Type type_)
Default constructor.
Definition: xmmPhrase.hpp:105
memory is shared with other data structures
unsigned int length_
Length of the phrase. If bimodal, it is the minimal length between modalities.
Definition: xmmPhrase.hpp:493
unsigned int input_length_
Length of the array of the input modality.
Definition: xmmPhrase.hpp:498
float ** data_
Pointer to the Data arrays.
Definition: xmmPhrase.hpp:514
Base Class for Generic Attributes.
Definition: xmmAttribute.hpp:105
PhraseEvent(PhraseEvent const &src)
Copy constructor.
Definition: xmmPhrase.hpp:111
Phrase * phrase
pointer to the source phrase
Definition: xmmPhrase.hpp:116
std::vector< std::string > column_names
labels of the columns of the phrase (e.g. descriptor names)
Definition: xmmPhrase.hpp:451
two modalities (i.e. 2 data arrays)
Base class for the definition of training sets.
Definition: xmmTrainingSet.hpp:46
Generator class for a specific type of events.
Definition: xmmEvents.hpp:47
bool bimodal_
Defines if the phrase is bimodal (true) or unimodal (false)
Definition: xmmPhrase.hpp:482
Attribute< unsigned int > dimension_input
Used in bimodal mode: dimension of the input modality.
Definition: xmmPhrase.hpp:441
Abstract class for handling JSON + File I/O.
Definition: xmmJson.hpp:50
Attribute< unsigned int > dimension
Total dimension of the phrase.
Definition: xmmPhrase.hpp:436
Type
Type of event.
Definition: xmmPhrase.hpp:93
Event that can be thrown by a phrase to a training set.
Definition: xmmPhrase.hpp:88
Definition: xmmAttribute.hpp:42
unsigned int max_length_
Allocated length (only used in own memory mode)
Definition: xmmPhrase.hpp:508
bool own_memory_
Defines if the phrase stores the data itself.
Definition: xmmPhrase.hpp:477
Type type
Type of event.
Definition: xmmPhrase.hpp:121
T * reallocate(T *src, unsigned int dim_src, unsigned int dim_dst)
Reallocate a C-like array (using c++ std::copy)
Definition: xmmPhrase.hpp:527
single modality (i.e. 1 data array)
bool empty_
true if the phrase does not contain any data
Definition: xmmPhrase.hpp:487
MemoryMode
Type of memory management for training sets and phrases.
Definition: xmmPhrase.hpp:50
memory is owned by the Phrase container.