Guest User

StreamingDenseDataGenerator.h

a guest
Sep 27th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.10 KB | None | 0 0
  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) 2012 Heiko Strathmann
  8.  */
  9.  
  10. #ifndef __STREAMINGDENSEDATAGENERATOR_H_
  11. #define __STREAMINGDENSEDATAGENERATOR_H_
  12.  
  13. #include <shogun/features/streaming/StreamingDenseFeatures.h>
  14.  
  15. namespace shogun
  16. {
  17.  
  18. enum EDenseDataGenerator
  19. {
  20.     DGD_NONE, DGD_MEAN_SHIFT, DGD_ROT_SYM_GAUSS
  21. };
  22.  
  23. /** @brief
  24.  * Class to generate dense features data via the streaming features interface.
  25.  * The core are pairs of methods to
  26.  * a) set the data model and parameters, and
  27.  * b) to generate a data vector using these model parameters
  28.  * Both methods are automatically called when calling get_next_example()
  29.  * This allows to treat generated data as a stream via the standard streaming
  30.  * features interface
  31.  */
  32. template <class T>
  33. class CStreamingDenseDataGenerator: public CStreamingDenseFeatures<T>
  34. {
  35. public:
  36.     /** Constructor */
  37.     CStreamingDenseDataGenerator();
  38.  
  39.     /** Destructor */
  40.     virtual ~CStreamingDenseDataGenerator();
  41.  
  42.     /** @return name of SG_SERIALIZABLE */
  43.     inline virtual const char* get_name() const
  44.     {
  45.         return "StreamingDenseDataGenerator";
  46.     }
  47.  
  48.     void set_mean_shift_model(T mean_shift, index_t dim);
  49.  
  50.     /** Takes a sample from two a distribution where each element
  51.      * is standard normally distributed, except for the first dimension,
  52.      * where the mean is shifted by a specified value.
  53.      *
  54.      * @param dim dimension of generated samples
  55.      * @param mean_shift is added to mean of first dimension
  56.      * @return dimx1 vector with sample
  57.      */
  58.     static SGVector<T> generate_mean_shift_data(index_t dim, T mean_shift);
  59.  
  60.     bool get_next_example();
  61. private:
  62.     /** registers all parameters and initializes variables with defaults */
  63.     void init();
  64.  
  65. protected:
  66.     /** model of data to generate */
  67.     EDenseDataGenerator m_model;
  68.  
  69.     /** parameters of model */
  70.     Parameter* m_model_parameters;
  71. };
  72.  
  73. }
  74.  
  75. #endif /* __STREAMINGDENSEDATAGENERATOR_H_ */
Add Comment
Please, Sign In to add comment