This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MultinomialLogRelModel::gradientForSample(const valarray<double>& sample_features, int label, valarray<double>& gradient) const | |
{ | |
double sum_exp = 0.0; | |
valarray<double> features(0.0, (num_sample_features + 1) * num_classes); | |
valarray<double> gradient_add(0.0, (num_sample_features + 1) * num_classes); | |
for (int k = 0; k < num_classes; ++k) | |
{ | |
featurize(sample_features, k, features); | |
double wf = inner_product(begin(model_weights), end(model_weights), begin(features), 0.0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MultinomialLogRelModel | |
{ | |
//Основные параметры модели | |
int num_classes; //Количество классов | |
int num_sample_features; //Количество признаков в объектах | |
valarray<double> model_weights; //Веса модели | |
double regularization_coeff; //Коэффициент регуляризации | |
double learning_rate; //Параметр шага в методе градиентного спуска | |
public: | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Правило ELEMENT -> elementToken | |
//Находит символ химического элемента, возвращает | |
//соответствующий объект класса Element | |
ChemSubStructure Element(): {Token t;} { | |
t = <ELEMENT> { return new Element( t.image ); } | |
} | |
//Правило ELEMENTARYGROUP -> elementaryGroupToken | |
//Находит "стандартную" группу атомов (SO4, CO3, OH), | |
//возвращает соответствующий объект класса ElementaryGroup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TOKEN: { "(" | ")" | | |
<NUM: (["0"-"9"])+> | | |
<ELEMENT: ( "H" | "He" | "Li" | "Be" | "B" | "C" | "N" | "O" | "F" | "Ne" | | |
"Na" | "Mg" | "Al" | "Si" | "P" | "S" | "Cl" | "Ar" | | |
"K" | "Ca" | "Sc" | "Ti" | "V" | "Cr" | "Mn" | "Fe" | "Co" | "Ni" | "Cu" | "Zn" | "Ga" | "Ge" | "As" | "Se" | "Br" | "Kr" | | |
"Rb" | "Sr" | "Y" | "Zr" | "Nb" | "Mo" | "Tc" | "Ru" | "Rh" | "Pd" | "Ag" | "Cd" | "In" | "Sn" | "Sb" | "Te" | "I" | "Xe" | | |
"Cs" | "Ba" | "Hf" | "Ta" | "W" | "Re" | "Os" | "Ir" | "Pt" | "Au" | "Hg" | "Tl" | "Pb" | "Bi" | "Po" | "At" | "Rn" | |
"La" | "Ce" | "Pr" | "Nd" | "Pm" | "Sm" | "Eu" | "Gd" | "Tb" | "Dy" | "Ho" | "Er" | "Tm" | "Yb" | "Lu" | | |
"Ac" | "Th" | "Pa" | "U" | "Np" | "Pu" | "Am" | "Cm" | "Bk" | "Cf" | "Es" | "Fm" | "Md" | "No" | "Lr")> | | |
<ELEMENTARYGROUP: ("OH" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>javacc-maven-plugin</artifactId> | |
<version>2.6</version> | |
<dependencies> | |
<dependency> | |
<groupId>net.java.dev.javacc</groupId> | |
<artifactId>javacc</artifactId> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void PrintSymbol(short code, ColorRGB *colorRGB) | |
{ | |
for (unsigned short y = 0; y < 8; ++y) { | |
for (unsigned short x = 0; x < 8; ++x) | |
{ | |
if (font8x8_basic[code][y] & (1 << x)) | |
Colorduino.SetPixel(7-x, y, colorRGB->r, colorRGB->g, colorRGB->b); | |
else | |
Colorduino.SetPixel(7-x, y, 0, 0, 0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Font | |
char font8x8_basic[10][8] = { | |
{ 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0) | |
{ 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1) | |
{ 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2) | |
{ 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3) | |
{ 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4) | |
{ 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5) | |
{ 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6) | |
{ 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//В заголовочном файле Colorduino.h определяется структура pixelRGB, | |
typedef struct pixelRGB { | |
unsigned char r; | |
unsigned char g; | |
unsigned char b; | |
} PixelRGB; | |
//...а так же класс ColorduinoObject, | |
class ColorduinoObject { | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//I2C bus support | |
#include <Wire.h> | |
//I2C | |
#include <LiquidCrystal_I2C.h> | |
//OneWire bus suport | |
#include <OneWire.h> | |
//DS18B20 temperature sensor support | |
#include <DallasTemperature.h> | |
//DS18B20 sensor pin | |
#define ONE_WIRE_BUS 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum { LED_PIN = 13 }; | |
void setup() | |
{ | |
pinMode(LED_PIN, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() | |
{ |