24 parser.set_free_vector_after_release(
false);
29 bool is_labelled, int32_t size) :
32 init(file, is_labelled, size);
34 parser.set_free_vector_after_release(
false);
41 REQUIRE(dense_features,
"%s::CStreamingDenseFeatures(): Features needed!\n")
49 init(file, is_labelled, size);
51 parser.set_free_vector_after_release(
false);
52 parser.set_free_vectors_on_destruct(
false);
58 SG_DEBUG(
"entering %s::~CStreamingDenseFeatures()\n", get_name())
60 current_vector.vector=NULL;
61 current_vector.vlen=0;
62 SG_DEBUG(
"leaving %s::~CStreamingDenseFeatures()\n", get_name())
71 parser.init(working_file, has_labels, 1);
72 parser.set_free_vector_after_release(
false);
73 parser.start_parser();
80 ASSERT(vec2_len==current_vector.vlen)
83 for (int32_t i=0; i<current_vector.vlen; i++)
84 result+=current_vector[i]*vec2[i];
92 ASSERT(vec2_len==current_vector.vlen)
95 for (int32_t i=0; i<current_vector.vlen; i++)
96 result+=current_vector[i]*vec2[i];
104 ASSERT(vec2_len==current_vector.vlen)
108 for (int32_t i=0; i<current_vector.vlen; i++)
109 vec2[i]+=alpha*CMath::abs(current_vector[i]);
113 for (int32_t i=0; i<current_vector.vlen; i++)
114 vec2[i]+=alpha*current_vector[i];
121 ASSERT(vec2_len==current_vector.vlen)
125 for (int32_t i=0; i<current_vector.vlen; i++)
126 vec2[i]+=alpha*CMath::abs(current_vector[i]);
130 for (int32_t i=0; i<current_vector.vlen; i++)
131 vec2[i]+=alpha*current_vector[i];
137 return current_vector.vlen;
153 parser.set_read_vector(&CStreamingFile::get_vector);
159 parser.set_read_vector_and_label(&CStreamingFile::get_vector_and_label);
162 #define GET_FEATURE_TYPE(f_type, sg_type) \ 163 template<> EFeatureType CStreamingDenseFeatures<sg_type>::get_feature_type() const \ 181 #undef GET_FEATURE_TYPE 184 void CStreamingDenseFeatures<T>::init()
190 current_vector.vector=NULL;
191 current_vector.vlen=-1;
197 void CStreamingDenseFeatures<T>::init(CStreamingFile* file,
bool is_labelled,
201 has_labels=is_labelled;
204 parser.init(file, is_labelled, size);
211 if (!parser.is_running())
226 current_vector.vlen, current_label);
234 return current_vector;
242 return current_label;
248 parser.finalize_example();
254 return current_vector.vlen;
276 if (len1!=current_vector.vlen)
278 "Lengths %d and %d not equal while computing dot product!\n", len1, current_vector.vlen);
286 return current_vector.vlen;
299 SG_DEBUG(
"entering %s(%p)::get_streamed_features(%d)\n", get_name(),
this,
305 for (
index_t i=0; i<num_elements; ++i)
308 if (!get_next_example())
310 SG_WARNING(
"%s::get_streamed_features(): ran out of streaming " 311 "data, reallocating matrix and returning!\n", get_name());
328 SG_DEBUG(
"%s::get_streamed_features(): allocating %dx%d matrix\n",
329 get_name(), current_vector.vlen, num_elements);
330 matrix=
SGMatrix<T>(current_vector.vlen, num_elements);
339 SG_ERROR(
"%s::get_streamed_features(): streamed vectors have " 340 "different dimensions. This is not allowed!\n",
345 memcpy(&matrix.
matrix[current_vector.vlen*i], vec.vector,
352 vec.display_vector(
"streamed vector");
364 SG_DEBUG(
"leaving %s(%p)::get_streamed_features(%d) and returning %dx%d " 365 "matrix\n", get_name(),
this, num_elements, matrix.
num_rows,
Class CStreamingFileFromDenseFeatures is a derived class of CStreamingFile which creates an input sou...
This class implements streaming features with dense feature vectors.
#define GET_FEATURE_TYPE(f_type, sg_type)
virtual bool get_next_example()
virtual void reset_stream()
EFeatureClass
shogun feature class
A Streaming File access class.
EMessageType get_loglevel() const
virtual EFeatureClass get_feature_class() const =0
Streaming features that support dot products among other operations.
virtual void end_parser()
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
CStreamingDenseFeatures()
virtual void start_parser()
virtual EFeatureType get_feature_type() const =0