ktv6

Radial.h

Dec 25th, 2019
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <numeric>
  6. #include <cmath>
  7.  
  8. using namespace std;
  9.  
  10. void HelpMessage() {
  11.     cout << "Usage: ./RadialNeuron study file name" << endl;
  12.     cout << "Study file format: XVALUE \\t YVALUE \\t " << endl;
  13. }
  14.  
  15. void gnuplotInit(FILE *gpipe) {
  16.     fprintf(gpipe, "set terminal X11\n");
  17.     fprintf(gpipe, "set nokey\n");
  18.     fprintf(gpipe, "set pointsize 1.5\n");
  19.     fprintf(gpipe, "set xrange [-2:12]\n");
  20.     fprintf(gpipe, "set yrange [-2:2]\n");
  21.     fprintf(gpipe, "set multiplot\n");
  22.     fprintf(gpipe, "\n");
  23. }
  24.  
  25.  
  26. typedef struct point2 {
  27.     double x, y ;  //нормированные координаты точки
  28.     double phi, theta ;  //в сферических координатах
  29.     double outValue;
  30.  
  31.     // Default constuctor
  32.     point2() {}
  33.    
  34.     // Constructor with x, y coordinates
  35.     point2(double _x, double _y) {
  36.         x = _x;
  37.         y = _y;
  38.     }
  39.  
  40.     void moveCenter(point2 X_k, double eta) {
  41.         double diffX, diffY;
  42.         diffX = X_k.x - x;
  43.         diffY = X_k.y - y;
  44.         x = x + eta * diffX;
  45.         y = y + eta * diffY;
  46.     }
  47.    
  48.     void printPoint() {
  49.         cout << "x = " << x << "\ty = " << y << endl;
  50.     }
  51. } point2;
  52.  
  53. double EuclideanDistance(const point2 a, const point2 b) {
  54.     double xDiff2, yDiff2;
  55.     xDiff2 = pow((a.x - b.x), 2);
  56.     yDiff2 = pow((a.y - b.y), 2);
  57.     return sqrt(xDiff2 + yDiff2);
  58. }
  59.  
  60.  
  61. class Radial {
  62. public:
  63.     Radial(point2, FILE*, FILE*, double);
  64.     point2 C;
  65.  
  66.     // eta setter
  67.     void set_eta(double);
  68.     //sigma setter
  69.     void set_sigma(double);
  70.     void etaInput();
  71.  
  72.     void StudyNeuron();
  73.     void StudySigmaOffline();
  74.  
  75.     double ActivationFunction(point2);
  76.     double ActivationFunctionWithSigma(point2, double);
  77.     point2 *StudyMass;
  78.  
  79.     int Test();
  80.  
  81.     double GradientMethod();
  82.  
  83. private:
  84.     int ClassValue;
  85.     FILE *gpipe;
  86.  
  87.     int StudyMassSize;
  88.  
  89.     void get_StudyData(FILE*);
  90.     void Norm(point2*);
  91.  
  92.     void PlotGreenPoint(int);
  93.  
  94.     double sigma = 1.;
  95.     double eta = 0.01;
  96.  
  97.     point2 testPoint;
  98.     double TargetFunction(int);
  99.    
  100.     void pltStudyMass();
  101.     void pltCenter();
  102.  
  103.     double getR(double);
  104. };
Add Comment
Please, Sign In to add comment