Guest User

.h

a guest
Sep 27th, 2012
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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> class CStreamingDenseDataGenerator: public CStreamingDenseFeatures<T>
  33. {
  34. public:
  35.     /** Constructor */
  36.     CStreamingDenseDataGenerator();
  37.  
  38.     /** Destructor */
  39.     virtual ~CStreamingDenseDataGenerator();
  40.  
  41.     /** @return name of SG_SERIALIZABLE */
  42.     inline virtual const char* get_name() const
  43.     {
  44.         return "StreamingDenseDataGenerator";
  45.     }
  46.  
  47.     void set_mean_shift_model(T mean_shift, index_t dim);
  48.  
  49.     /** Takes a sample from two a distribution where each element
  50.      * is standard normally distributed, except for the first dimension,
  51.      * where the mean is shifted by a specified value.
  52.      *
  53.      * @param dim dimension of generated samples
  54.      * @param mean_shift is added to mean of first dimension
  55.      * @return dimx1 vector with sample
  56.      */
  57.     static SGVector<T> generate_mean_shift_data(index_t dim, T mean_shift);
  58.  
  59.     bool get_next_example();
  60. private:
  61.     /** registers all parameters and initializes variables with defaults */
  62.     void init();
  63.  
  64. protected:
  65.     /** model of data to generate */
  66.     EDenseDataGenerator m_model;
  67.  
  68.     /** parameters of model */
  69.     Parameter* m_model_parameters;
  70. };
  71.  
  72. }
  73.  
  74. #endif /* __STREAMINGDENSEDATAGENERATOR_H_ */
Advertisement
Add Comment
Please, Sign In to add comment