Skip to content

Instantly share code, notes, and snippets.

View ollewelin's full-sized avatar

Olle Welin ollewelin

View GitHub Profile
@ollewelin
ollewelin / gist:d48ef585fe6c9b049d026abb91e027ac
Last active June 11, 2017 12:37
Stacked Autoencoder 2 layer L1 and L2, Deep Unsupervised Machine Learning, C++ Raspicam OpenCV
///Stacked Autoencoder 2 layer L1 and L2
///Hit <?> to read help menu.
///Now USE_IND_NOISE switch ON make more realistoc gabor filter like feature on first layer
///TODO: Not yet show the image representation off each L2 feature projected on a L1 layer image representation
int Pause_cam =0;
#define USE_RASPICAM_INPUT //If you want to use raspicam input data
//#define USE_MNIST_DATABASE// Here read the t10k-images-idx3-ubyte file
//Here use real image from raspicam take random part 10x10 pixel and put in to the autoencoder
//test stacking autoencoder 2 layer 4x input same Layer 1 (L1) filter down to the Layer 2 (L2)
@ollewelin
ollewelin / gist:a90b8606311e9270fd66fc3bab5153c3
Last active June 11, 2017 20:20
More test options Stacked Autoencoder + Raspicam
///Stacked Autoencoder 2 layer L1 and L2
///TODO: Not yet show the image representation off each L2 feature projected on a L1 layer image representation
int Pause_cam =0;
#define USE_RASPICAM_INPUT //If you want to use raspicam input data
//#define USE_MNIST_DATABASE// Here read the t10k-images-idx3-ubyte file
//Here use real image from raspicam take random part 10x10 pixel and put in to the autoencoder
//test stacking autoencoder 2 layer 4x input same Layer 1 (L1) filter down to the Layer 2 (L2)
//L2 input nodes = 4x L1 nodes
@ollewelin
ollewelin / main.cpp
Last active July 7, 2017 17:16
Autoencoder unsupervised learning Relu tied weight and Supervised Learning Logistic Regression. MNIST test
///Now with fully connected Logistic Regression network Supervised Learning
///************* Parameters and things regarding fully connected network **************
int fully_conn_backprop =0;
const int C_fully_hidd_nodes = 200;
const int C_fully_out_nodes = 10;
int fully_hidd_nodes = C_fully_hidd_nodes;
int fully_out_nodes = C_fully_out_nodes;
int drop_out_percent = 50;/// 50% dropout percent hidden nodes during training
int verification = 0;
float Error_level=0.0f;
@ollewelin
ollewelin / c_func.c
Last active July 27, 2017 21:09
Convolution Neural Network CNN2. 3-layer Autoencoder. Convolution and Max Pooling. Fully connected not attached yet
#include <stdio.h>
#include <stdlib.h>// exit(0);
float abs_value(float signed_value)
{
float abs_v;
abs_v = signed_value;
if(abs_v < 0)
{
abs_v = -abs_v;
@ollewelin
ollewelin / c_func.c
Last active November 26, 2017 20:34
Convolution Neural Network test with MNIST digits. First complete version with fully connected network
#include <stdio.h>
#include <stdlib.h>// exit(0);
float abs_value(float signed_value)
{
float abs_v;
abs_v = signed_value;
if(abs_v < 0)
{
abs_v = -abs_v;
@ollewelin
ollewelin / c_func.c
Last active August 22, 2017 13:47
Convolution Neural Network 2 Layer convolution feature test on IMAGE 2 categorys
#include <stdio.h>
#include <stdlib.h>// exit(0);
float abs_value(float signed_value)
{
float abs_v;
abs_v = signed_value;
if(abs_v < 0)
{
abs_v = -abs_v;
@ollewelin
ollewelin / main.cpp
Last active November 17, 2017 20:43
Reinforced Machine Learning Pinball Game BASIC VERSION
/// Add gamma parameter and use dice and network probability for make action decisions UP/DOWN.
/// Example of Reinforced Machine Learning attached on a simple Pinball game
/// The enviroment (enviroment = data feedback) for the Agient (Agient = machine learning system)
/// is the raw pixels 50x50 pixels (2500 input nodes) and 200 hidden nodes on 100 frames
/// So the input to hidden weights is 50x50x100x200 x4 bytes (float) = is 200Mbytes huges but it work anyway!!
///Enhancment to do in future.
///TODO: Add some layers of Convolutions (with unsupervised Learning for learning feature patches) will probably enhance preformance.
///TODO: Maybe add bias weigth is a good idee to enhance preformance or stability during training.
///#define USE_PRINT_OUTPUT_NODE_VALUE ///Uncomment this to see print out of output node value. Only used for evaluation
#include <opencv2/highgui/highgui.hpp> // OpenCV window I/O
@ollewelin
ollewelin / main.cpp
Last active November 17, 2017 20:42
Reinforcement Learning pinball game with user configurable parameters
/// Change some settings 2017-10-25
/// Only dependancy is OpenCV C++ library need to be installed
/// Example of Reinforced Machine Learning attached on a simple Pinball game
/// The enviroment (enviroment = data feedback) for the Agient (Agient = machine learning system)
/// is the raw pixels 50x50 pixels (2500 input nodes) and 200 hidden nodes on 100 frames
/// So the input to hidden weights is 50x50x100x200 x4 bytes (float) = is 200Mbytes huges but it work anyway!!
///Enhancment to do in future.
///TODO: Add some layers of Convolutions (with unsupervised Learning for learning feature patches) will probably enhance preformance.
///TODO: Maybe add bias weigth is a good idee to enhance preformance or stability during training.
#include <opencv2/highgui/highgui.hpp> // OpenCV window I/O
@ollewelin
ollewelin / main.ino
Last active September 29, 2023 13:00
3-phase PWM with deadtime 31.25kHz Arduino UNO. 6 transistors PWM
//This is a code made to run 3-phase PWM drive stage with 6-transistors, in other words 3 half bridge transistors with an Arduino UNO
//This setup is made with User settings of DEAD TIME. So here the the dead time can be adjusted by user. const int dead_time = 10;//10 = 0.625 us
//The PWM work here with fix frequancy of 31.25kHz (Other settings may not work proper when use all 3 TIMERS, if you want more flexibilty use Arduino MEGA 2560 or some other plattform)
//Olle Welin [email protected]
// TL Transistor Low side of half bridge pair
// TH Transistor High side of half bridge pair
// PWM assignement at Arduino UNO is by following:
//~6 TL, PH0, TMR0, pwm_ph0 data value
@ollewelin
ollewelin / main.ino
Last active May 12, 2022 14:52
3-phase motor PWM drive open loop motor
//This is a code made to run 3-phase PWM drive stage with 6-transistors, in other words 3 half bridge transistors with an Arduino UNO
//This setup is made with User settings of DEAD TIME. So here the the dead time can be adjusted by user. const int dead_time = 10;//10 = 0.625 us
//The PWM work here with fix frequancy of 31.25kHz (Other settings may not work proper when use all 3 TIMERS, if you want more flexibilty use Arduino MEGA 2560 or some other plattform)
//Olle Welin [email protected]
// TL Transistor Low side of half bridge pair
// TH Transistor High side of half bridge pair
// PWM assignement at Arduino UNO is by following:
//~6 TL, PH0, TMR0, pwm_ph0 data value