SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SGObject.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2008-2009 Soeren Sonnenburg
8  * Written (W) 2011-2013 Heiko Strathmann
9  * Written (W) 2013-2014 Thoralf Klein
10  * Copyright (C) 2008-2009 Fraunhofer Institute FIRST and Max Planck Society
11  */
12 
13 #include <shogun/lib/config.h>
14 #include <shogun/lib/memory.h>
15 #include <shogun/lib/RefCount.h>
16 
17 #include <shogun/base/SGObject.h>
18 #include <shogun/base/Version.h>
19 #include <shogun/base/Parameter.h>
20 #include <shogun/base/DynArray.h>
21 #include <shogun/lib/Map.h>
22 #include <shogun/lib/SGVector.h>
25 
26 #include <shogun/base/class_list.h>
27 
28 #include <stdlib.h>
29 #include <stdio.h>
30 
31 #ifdef HAVE_CXX11
32 #include <unordered_map>
33 #else
34 #include <map>
35 #endif
36 
37 namespace shogun
38 {
39 #ifdef HAVE_CXX11
40  typedef std::unordered_map<BaseTag, Any> ParametersMap;
41 #else
42  typedef std::map<BaseTag, Any> ParametersMap;
43 #endif
44 
46  {
47  public:
48  void set(const BaseTag& tag, const Any& any)
49  {
50  map[tag] = any;
51  }
52 
53  Any get(const BaseTag& tag) const
54  {
55  if(!has(tag))
56  return Any();
57  return map.at(tag);
58  }
59 
60  bool has(const BaseTag& tag) const
61  {
62  return map.find(tag) != map.end();
63  }
64 
65  ParametersMap map;
66  };
67 
68  class Parallel;
69 
70  extern Parallel* sg_parallel;
71  extern SGIO* sg_io;
72  extern Version* sg_version;
73 
74  template<> void CSGObject::set_generic<bool>()
75  {
76  m_generic = PT_BOOL;
77  }
78 
79  template<> void CSGObject::set_generic<char>()
80  {
81  m_generic = PT_CHAR;
82  }
83 
84  template<> void CSGObject::set_generic<int8_t>()
85  {
86  m_generic = PT_INT8;
87  }
88 
89  template<> void CSGObject::set_generic<uint8_t>()
90  {
91  m_generic = PT_UINT8;
92  }
93 
94  template<> void CSGObject::set_generic<int16_t>()
95  {
96  m_generic = PT_INT16;
97  }
98 
99  template<> void CSGObject::set_generic<uint16_t>()
100  {
101  m_generic = PT_UINT16;
102  }
103 
104  template<> void CSGObject::set_generic<int32_t>()
105  {
106  m_generic = PT_INT32;
107  }
108 
109  template<> void CSGObject::set_generic<uint32_t>()
110  {
111  m_generic = PT_UINT32;
112  }
113 
114  template<> void CSGObject::set_generic<int64_t>()
115  {
116  m_generic = PT_INT64;
117  }
118 
119  template<> void CSGObject::set_generic<uint64_t>()
120  {
121  m_generic = PT_UINT64;
122  }
123 
124  template<> void CSGObject::set_generic<float32_t>()
125  {
126  m_generic = PT_FLOAT32;
127  }
128 
129  template<> void CSGObject::set_generic<float64_t>()
130  {
131  m_generic = PT_FLOAT64;
132  }
133 
134  template<> void CSGObject::set_generic<floatmax_t>()
135  {
136  m_generic = PT_FLOATMAX;
137  }
138 
139  template<> void CSGObject::set_generic<CSGObject*>()
140  {
141  m_generic = PT_SGOBJECT;
142  }
143 
144  template<> void CSGObject::set_generic<complex128_t>()
145  {
146  m_generic = PT_COMPLEX128;
147  }
148 
149 } /* namespace shogun */
150 
151 using namespace shogun;
152 
154 {
155  init();
156  set_global_objects();
157  m_refcount = new RefCount(0);
158 
159  SG_SGCDEBUG("SGObject created (%p)\n", this)
160 }
161 
163 : self(), io(orig.io), parallel(orig.parallel), version(orig.version)
164 {
165  init();
166  set_global_objects();
167  m_refcount = new RefCount(0);
168 
169  SG_SGCDEBUG("SGObject copied (%p)\n", this)
170 }
171 
173 {
174  SG_SGCDEBUG("SGObject destroyed (%p)\n", this)
175 
176  unset_global_objects();
177  delete m_parameters;
179  delete m_gradient_parameters;
180  delete m_refcount;
181 }
182 
183 #ifdef USE_REFERENCE_COUNTING
184 int32_t CSGObject::ref()
185 {
186  int32_t count = m_refcount->ref();
187  SG_SGCDEBUG("ref() refcount %ld obj %s (%p) increased\n", count, this->get_name(), this)
188  return m_refcount->ref_count();
189 }
190 
191 int32_t CSGObject::ref_count()
192 {
193  int32_t count = m_refcount->ref_count();
194  SG_SGCDEBUG("ref_count(): refcount %d, obj %s (%p)\n", count, this->get_name(), this)
195  return m_refcount->ref_count();
196 }
197 
198 int32_t CSGObject::unref()
199 {
200  int32_t count = m_refcount->unref();
201  if (count<=0)
202  {
203  SG_SGCDEBUG("unref() refcount %ld, obj %s (%p) destroying\n", count, this->get_name(), this)
204  delete this;
205  return 0;
206  }
207  else
208  {
209  SG_SGCDEBUG("unref() refcount %ld obj %s (%p) decreased\n", count, this->get_name(), this)
210  return m_refcount->ref_count();
211  }
212 }
213 #endif //USE_REFERENCE_COUNTING
214 
215 #ifdef TRACE_MEMORY_ALLOCS
216 #include <shogun/lib/Map.h>
217 extern CMap<void*, shogun::MemoryBlock>* sg_mallocs;
218 
219 void CSGObject::list_memory_allocs()
220 {
221  shogun::list_memory_allocs();
222 }
223 #endif
224 
226 {
228  return NULL;
229 }
230 
232 {
234  return NULL;
235 }
236 
237 void CSGObject::set_global_objects()
238 {
239  if (!sg_io || !sg_parallel || !sg_version)
240  {
241  fprintf(stderr, "call init_shogun() before using the library, dying.\n");
242  exit(1);
243  }
244 
245  SG_REF(sg_io);
248 
249  io=sg_io;
252 }
253 
254 void CSGObject::unset_global_objects()
255 {
256  SG_UNREF(version);
258  SG_UNREF(io);
259 }
260 
262 {
263  SG_REF(new_io);
264  SG_UNREF(sg_io);
265  sg_io=new_io;
266 }
267 
269 {
270  SG_REF(sg_io);
271  return sg_io;
272 }
273 
275 {
276  SG_REF(new_parallel);
278  sg_parallel=new_parallel;
279 }
280 
282 {
283  SG_DEBUG("entering\n")
284 
285  uint32_t carry=0;
286  uint32_t length=0;
287 
288  m_hash=0;
289  get_parameter_incremental_hash(m_hash, carry, length);
291 
292  SG_DEBUG("leaving\n")
293 }
294 
296 {
297  SG_DEBUG("entering\n")
298 
299  uint32_t hash=0;
300  uint32_t carry=0;
301  uint32_t length=0;
302 
303  get_parameter_incremental_hash(hash, carry, length);
304  hash=CHash::FinalizeIncrementalMurmurHash3(hash, carry, length);
305 
306  SG_DEBUG("leaving\n")
307  return (m_hash!=hash);
308 }
309 
311 {
313  return sg_parallel;
314 }
315 
317 {
318  SG_REF(new_version);
320  sg_version=new_version;
321 }
322 
324 {
326  return sg_version;
327 }
328 
329 bool CSGObject::is_generic(EPrimitiveType* generic) const
330 {
331  *generic = m_generic;
332 
333  return m_generic != PT_NOT_GENERIC;
334 }
335 
337 {
338  m_generic = PT_NOT_GENERIC;
339 }
340 
341 void CSGObject::print_serializable(const char* prefix)
342 {
343  SG_PRINT("\n%s\n================================================================================\n", get_name())
344  m_parameters->print(prefix);
345 }
346 
348  const char* prefix)
349 {
350  SG_DEBUG("START SAVING CSGObject '%s'\n", get_name())
351  try
352  {
354  }
355  catch (ShogunException& e)
356  {
357  SG_SWARNING("%s%s::save_serializable_pre(): ShogunException: "
358  "%s\n", prefix, get_name(),
360  return false;
361  }
362 
363  if (!m_save_pre_called)
364  {
365  SG_SWARNING("%s%s::save_serializable_pre(): Implementation "
366  "error: BASE_CLASS::SAVE_SERIALIZABLE_PRE() not "
367  "called!\n", prefix, get_name());
368  return false;
369  }
370 
371  if (!m_parameters->save(file, prefix))
372  return false;
373 
374  try
375  {
377  }
378  catch (ShogunException& e)
379  {
380  SG_SWARNING("%s%s::save_serializable_post(): ShogunException: "
381  "%s\n", prefix, get_name(),
383  return false;
384  }
385 
386  if (!m_save_post_called)
387  {
388  SG_SWARNING("%s%s::save_serializable_post(): Implementation "
389  "error: BASE_CLASS::SAVE_SERIALIZABLE_POST() not "
390  "called!\n", prefix, get_name());
391  return false;
392  }
393 
394  if (prefix == NULL || *prefix == '\0')
395  file->close();
396 
397  SG_DEBUG("DONE SAVING CSGObject '%s' (%p)\n", get_name(), this)
398 
399  return true;
400 }
401 
403  const char* prefix)
404 {
405  REQUIRE(file != NULL, "Serializable file object should be != NULL\n");
406 
407  SG_DEBUG("START LOADING CSGObject '%s'\n", get_name())
408  try
409  {
411  }
412  catch (ShogunException& e)
413  {
414  SG_SWARNING("%s%s::load_serializable_pre(): ShogunException: "
415  "%s\n", prefix, get_name(),
417  return false;
418  }
419  if (!m_load_pre_called)
420  {
421  SG_SWARNING("%s%s::load_serializable_pre(): Implementation "
422  "error: BASE_CLASS::LOAD_SERIALIZABLE_PRE() not "
423  "called!\n", prefix, get_name());
424  return false;
425  }
426 
427  if (!m_parameters->load(file, prefix))
428  return false;
429 
430  try
431  {
433  }
434  catch (ShogunException& e)
435  {
436  SG_SWARNING("%s%s::load_serializable_post(): ShogunException: "
437  "%s\n", prefix, get_name(),
439  return false;
440  }
441 
442  if (!m_load_post_called)
443  {
444  SG_SWARNING("%s%s::load_serializable_post(): Implementation "
445  "error: BASE_CLASS::LOAD_SERIALIZABLE_POST() not "
446  "called!\n", prefix, get_name());
447  return false;
448  }
449  SG_DEBUG("DONE LOADING CSGObject '%s' (%p)\n", get_name(), this)
450 
451  return true;
452 }
453 
455 {
456  m_load_pre_called = true;
457 }
458 
460 {
461  m_load_post_called = true;
462 }
463 
465 {
466  m_save_pre_called = true;
467 }
468 
470 {
471  m_save_post_called = true;
472 }
473 
474 #ifdef TRACE_MEMORY_ALLOCS
475 #include <shogun/lib/Map.h>
476 extern CMap<void*, shogun::MemoryBlock>* sg_mallocs;
477 #endif
478 
479 void CSGObject::init()
480 {
481 #ifdef TRACE_MEMORY_ALLOCS
482  if (sg_mallocs)
483  {
484  int32_t idx=sg_mallocs->index_of(this);
485  if (idx>-1)
486  {
487  MemoryBlock* b=sg_mallocs->get_element_ptr(idx);
488  b->set_sgobject();
489  }
490  }
491 #endif
492 
493  io = NULL;
494  parallel = NULL;
495  version = NULL;
496  m_parameters = new Parameter();
499  m_generic = PT_NOT_GENERIC;
500  m_load_pre_called = false;
501  m_load_post_called = false;
502  m_save_pre_called = false;
503  m_save_post_called = false;
504  m_hash = 0;
505 }
506 
508 {
509  SG_PRINT("parameters available for model selection for %s:\n", get_name())
510 
512 
513  if (!num_param)
514  SG_PRINT("\tnone\n")
515 
516  for (index_t i=0; i<num_param; i++)
517  {
519  index_t l=200;
520  char* type=SG_MALLOC(char, l);
521  if (type)
522  {
523  current->m_datatype.to_string(type, l);
524  SG_PRINT("\t%s (%s): %s\n", current->m_name, current->m_description,
525  type);
526  SG_FREE(type);
527  }
528  }
529 }
530 
532 {
534 
535  SGStringList<char> result(num_param, -1);
536 
537  index_t max_string_length=-1;
538 
539  for (index_t i=0; i<num_param; i++)
540  {
542  index_t len=strlen(name);
543  // +1 to have a zero terminated string
544  result.strings[i]=SGString<char>(name, len+1);
545 
546  if (len>max_string_length)
547  max_string_length=len;
548  }
549 
550  result.max_string_length=max_string_length;
551 
552  return result;
553 }
554 
555 char* CSGObject::get_modsel_param_descr(const char* param_name)
556 {
557  index_t index=get_modsel_param_index(param_name);
558 
559  if (index<0)
560  {
561  SG_ERROR("There is no model selection parameter called \"%s\" for %s",
562  param_name, get_name());
563  }
564 
566 }
567 
569 {
570  /* use fact that names extracted from below method are in same order than
571  * in m_model_selection_parameters variable */
573 
574  /* search for parameter with provided name */
575  index_t index=-1;
576  for (index_t i=0; i<names.num_strings; i++)
577  {
579  if (!strcmp(param_name, current->m_name))
580  {
581  index=i;
582  break;
583  }
584  }
585 
586  return index;
587 }
588 
589 void CSGObject::get_parameter_incremental_hash(uint32_t& hash, uint32_t& carry,
590  uint32_t& total_length)
591 {
592  for (index_t i=0; i<m_parameters->get_num_parameters(); i++)
593  {
595 
596  SG_DEBUG("Updating hash for parameter %s.%s\n", get_name(), p->m_name);
597 
598  if (p->m_datatype.m_ptype == PT_SGOBJECT)
599  {
600  if (p->m_datatype.m_ctype == CT_SCALAR)
601  {
602  CSGObject* child = *((CSGObject**)(p->m_parameter));
603 
604  if (child)
605  {
606  child->get_parameter_incremental_hash(hash, carry,
607  total_length);
608  }
609  }
610  else if (p->m_datatype.m_ctype==CT_VECTOR ||
611  p->m_datatype.m_ctype==CT_SGVECTOR)
612  {
613  CSGObject** child=(*(CSGObject***)(p->m_parameter));
614 
615  for (index_t j=0; j<*(p->m_datatype.m_length_y); j++)
616  {
617  if (child[j])
618  {
619  child[j]->get_parameter_incremental_hash(hash, carry,
620  total_length);
621  }
622  }
623  }
624  }
625  else
626  p->get_incremental_hash(hash, carry, total_length);
627  }
628 }
629 
631 {
633  {
635  dict->add(p, this);
636  }
637 
639  {
641  CSGObject* child=*(CSGObject**)(p->m_parameter);
642 
643  if ((p->m_datatype.m_ptype == PT_SGOBJECT) &&
644  (p->m_datatype.m_ctype == CT_SCALAR) && child)
645  {
647  }
648  }
649 }
650 
651 bool CSGObject::equals(CSGObject* other, float64_t accuracy, bool tolerant)
652 {
653  SG_DEBUG("entering %s::equals()\n", get_name());
654 
655  if (other==this)
656  {
657  SG_DEBUG("leaving %s::equals(): other object is me\n", get_name());
658  return true;
659  }
660 
661  if (!other)
662  {
663  SG_DEBUG("leaving %s::equals(): other object is NULL\n", get_name());
664  return false;
665  }
666 
667  SG_DEBUG("comparing \"%s\" to \"%s\"\n", get_name(), other->get_name());
668 
669  /* a crude type check based on the get_name */
670  if (strcmp(other->get_name(), get_name()))
671  {
672  SG_INFO("leaving %s::equals(): name of other object differs\n", get_name());
673  return false;
674  }
675 
676  /* should not be necessary but just ot be sure that type has not changed.
677  * Will assume that parameters are in same order with same name from here */
679  {
680  SG_INFO("leaving %s::equals(): number of parameters of other object "
681  "differs\n", get_name());
682  return false;
683  }
684 
685  for (index_t i=0; i<m_parameters->get_num_parameters(); ++i)
686  {
687  SG_DEBUG("comparing parameter %d\n", i);
688 
689  TParameter* this_param=m_parameters->get_parameter(i);
690  TParameter* other_param=other->m_parameters->get_parameter(i);
691 
692  /* some checks to make sure parameters have same order and names and
693  * are not NULL. Should never be the case but check anyway. */
694  if (!this_param && !other_param)
695  continue;
696 
697  if (!this_param && other_param)
698  {
699  SG_DEBUG("leaving %s::equals(): parameter %d is NULL where other's "
700  "parameter \"%s\" is not\n", get_name(), other_param->m_name);
701  return false;
702  }
703 
704  if (this_param && !other_param)
705  {
706  SG_DEBUG("leaving %s::equals(): parameter %d is \"%s\" where other's "
707  "parameter is NULL\n", get_name(), this_param->m_name);
708  return false;
709  }
710 
711  SG_DEBUG("comparing parameter \"%s\" to other's \"%s\"\n",
712  this_param->m_name, other_param->m_name);
713 
714  /* hard-wired exception for DynamicObjectArray parameter num_elements */
715  if (!strcmp("DynamicObjectArray", get_name()) &&
716  !strcmp(this_param->m_name, "num_elements") &&
717  !strcmp(other_param->m_name, "num_elements"))
718  {
719  SG_DEBUG("Ignoring DynamicObjectArray::num_elements field\n");
720  continue;
721  }
722 
723  /* hard-wired exception for DynamicArray parameter num_elements */
724  if (!strcmp("DynamicArray", get_name()) &&
725  !strcmp(this_param->m_name, "num_elements") &&
726  !strcmp(other_param->m_name, "num_elements"))
727  {
728  SG_DEBUG("Ignoring DynamicArray::num_elements field\n");
729  continue;
730  }
731 
732  /* use equals method of TParameter from here */
733  if (!this_param->equals(other_param, accuracy, tolerant))
734  {
735  SG_INFO("leaving %s::equals(): parameters at position %d with name"
736  " \"%s\" differs from other object parameter with name "
737  "\"%s\"\n",
738  get_name(), i, this_param->m_name, other_param->m_name);
739  return false;
740  }
741  }
742 
743  SG_DEBUG("leaving %s::equals(): object are equal\n", get_name());
744  return true;
745 }
746 
748 {
749  SG_DEBUG("entering %s::clone()\n", get_name());
750 
751  SG_DEBUG("constructing an empty instance of %s\n", get_name());
752  CSGObject* copy=new_sgserializable(get_name(), this->m_generic);
753 
754  SG_REF(copy);
755 
756  REQUIRE(copy, "Could not create empty instance of \"%s\". The reason for "
757  "this usually is that get_name() of the class returns something "
758  "wrong, or that a class has a wrongly set generic type.\n",
759  get_name());
760 
761  for (index_t i=0; i<m_parameters->get_num_parameters(); ++i)
762  {
763  SG_DEBUG("cloning parameter \"%s\" at index %d\n",
765 
767  {
768  SG_DEBUG("leaving %s::clone(): Clone failed. Returning NULL\n",
769  get_name());
770  return NULL;
771  }
772  }
773 
774  SG_DEBUG("leaving %s::clone(): Clone successful\n", get_name());
775  return copy;
776 }
777 
778 void CSGObject::set_with_base_tag(const BaseTag& _tag, const Any& any)
779 {
780  self->set(_tag, any);
781 }
782 
783 Any CSGObject::get_with_base_tag(const BaseTag& _tag) const
784 {
785  Any any = self->get(_tag);
786  if(any.empty())
787  {
788  SG_ERROR("There is no parameter called \"%s\" in %s",
789  _tag.name().c_str(), get_name());
790  }
791  return any;
792 }
793 
794 bool CSGObject::has_with_base_tag(const BaseTag& _tag) const
795 {
796  return self->has(_tag);
797 }
virtual const char * get_name() const =0
SGStringList< char > get_modelsel_names()
Definition: SGObject.cpp:531
#define SG_INFO(...)
Definition: SGIO.h:118
template class SGStringList
Definition: SGObject.h:43
Parallel * get_global_parallel()
Definition: SGObject.cpp:310
virtual void update_parameter_hash()
Definition: SGObject.cpp:281
int32_t index_of(const K &key)
Definition: Map.h:154
int32_t index_t
Definition: common.h:62
virtual int32_t get_num_parameters()
virtual CSGObject * clone()
Definition: SGObject.cpp:747
Base class for all tags. This class stores name and not the type information for a shogun object...
Definition: basetag.h:48
Class ShogunException defines an exception which is thrown whenever an error inside of shogun occurs...
int32_t ref_count()
Definition: RefCount.cpp:31
virtual CSGObject * shallow_copy() const
Definition: SGObject.cpp:225
#define SG_SWARNING(...)
Definition: SGIO.h:178
void unset_generic()
Definition: SGObject.cpp:336
TParameter * get_parameter(int32_t idx)
Version * get_global_version()
Definition: SGObject.cpp:323
parameter struct
virtual void save_serializable_pre()
Definition: SGObject.cpp:464
#define SG_ERROR(...)
Definition: SGIO.h:129
#define REQUIRE(x,...)
Definition: SGIO.h:206
virtual bool is_generic(EPrimitiveType *generic) const
Definition: SGObject.cpp:329
#define SG_NOTIMPLEMENTED
Definition: SGIO.h:139
Allows to store objects of arbitrary types by using a BaseAnyPolicy and provides a type agnostic API...
Definition: any.h:159
Parameter * m_parameters
Definition: SGObject.h:546
virtual bool load_serializable(CSerializableFile *file, const char *prefix="")
Definition: SGObject.cpp:402
virtual void print(const char *prefix="")
Definition: Parameter.cpp:2762
static uint32_t FinalizeIncrementalMurmurHash3(uint32_t h, uint32_t carry, uint32_t total_length)
Definition: Hash.cpp:376
Parallel * parallel
Definition: SGObject.h:540
#define SG_REF(x)
Definition: SGObject.h:54
virtual bool load(CSerializableFile *file, const char *prefix="")
Definition: Parameter.cpp:2781
Version * sg_version
Definition: init.cpp:37
std::map< BaseTag, Any > ParametersMap
Definition: SGObject.cpp:42
T * get_element_ptr(int32_t index)
Definition: Map.h:232
std::string name() const
Definition: basetag.h:79
char * get_modsel_param_descr(const char *param_name)
Definition: SGObject.cpp:555
bool has(const BaseTag &tag) const
Definition: SGObject.cpp:60
bool equals(TParameter *other, float64_t accuracy=0.0, bool tolerant=false)
Definition: Parameter.cpp:2962
void set(const Tag< T > &_tag, const T &value)
Definition: SGObject.h:328
int32_t add(const K &key, const T &data)
Definition: Map.h:101
TSGDataType m_datatype
#define SG_PRINT(...)
Definition: SGIO.h:137
Parallel * sg_parallel
Definition: init.cpp:35
Parameter class.
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:115
virtual ~CSGObject()
Definition: SGObject.cpp:172
SGIO * sg_io
Definition: init.cpp:36
void build_gradient_parameter_dictionary(CMap< TParameter *, CSGObject * > *dict)
Definition: SGObject.cpp:630
int32_t unref()
Definition: RefCount.cpp:18
double float64_t
Definition: common.h:50
Version * version
Definition: SGObject.h:543
virtual bool save(CSerializableFile *file, const char *prefix="")
Definition: Parameter.cpp:2769
virtual void save_serializable_post()
Definition: SGObject.cpp:469
void print_modsel_params()
Definition: SGObject.cpp:507
int32_t ref()
Definition: RefCount.cpp:5
CSGObject * new_sgserializable(const char *sgserializable_name, EPrimitiveType generic)
ParametersMap map
Definition: SGObject.cpp:65
Class Version provides version information.
Definition: Version.h:28
Parameter * m_model_selection_parameters
Definition: SGObject.h:549
void get_incremental_hash(uint32_t &hash, uint32_t &carry, uint32_t &total_length)
Definition: Parameter.cpp:2423
virtual bool equals(CSGObject *other, float64_t accuracy=0.0, bool tolerant=false)
Definition: SGObject.cpp:651
index_t * m_length_y
Definition: DataType.h:78
virtual CSGObject * deep_copy() const
Definition: SGObject.cpp:231
void set_global_parallel(Parallel *parallel)
Definition: SGObject.cpp:274
void to_string(char *dest, size_t n) const
Definition: DataType.cpp:145
virtual void load_serializable_pre()
Definition: SGObject.cpp:454
virtual void load_serializable_post()
Definition: SGObject.cpp:459
EContainerType m_ctype
Definition: DataType.h:71
#define SG_UNREF(x)
Definition: SGObject.h:55
Class Parallel provides helper functions for multithreading.
Definition: Parallel.h:27
#define SG_DEBUG(...)
Definition: SGIO.h:107
virtual bool save_serializable(CSerializableFile *file, const char *prefix="")
Definition: SGObject.cpp:347
const char * get_exception_string()
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
#define SG_SGCDEBUG(...)
Definition: SGIO.h:163
SGIO * get_global_io()
Definition: SGObject.cpp:268
#define PT_NOT_GENERIC
Definition: DataType.h:21
SGString< T > * strings
Definition: SGStringList.h:88
index_t get_modsel_param_index(const char *param_name)
Definition: SGObject.cpp:568
void set_global_io(SGIO *io)
Definition: SGObject.cpp:261
uint32_t m_hash
Definition: SGObject.h:555
bool copy(TParameter *target)
Definition: Parameter.cpp:3770
void set(const BaseTag &tag, const Any &any)
Definition: SGObject.cpp:48
EPrimitiveType m_ptype
Definition: DataType.h:75
Class SGIO, used to do input output operations throughout shogun.
Definition: SGIO.h:243
Parameter * m_gradient_parameters
Definition: SGObject.h:552
virtual void print_serializable(const char *prefix="")
Definition: SGObject.cpp:341
virtual bool parameter_hash_changed()
Definition: SGObject.cpp:295
bool empty() const
Definition: any.h:247
void set_global_version(Version *version)
Definition: SGObject.cpp:316
the class CMap, a map based on the hash-table. w: http://en.wikipedia.org/wiki/Hash_table ...
Definition: SGObject.h:39

SHOGUN Machine Learning Toolbox - Documentation