Skip to content

Instantly share code, notes, and snippets.

View ollewelin's full-sized avatar

Olle Welin ollewelin

View GitHub Profile
@ollewelin
ollewelin / gist:4d9164fa30a9403e87c2ad193655f42a
Created May 19, 2018 17:01
Installation setup CUDA, cuDNN, OpenCV 3.4.1
Ubuntu 16.04
sudo apt-get update
CMake GUI
sudo apt-get install cmake-qt-gui
GTK2.0
sudo apt-get install gtk2.0
sudo apt-get install build-essential libgtk2.0-dev
==============
@ollewelin
ollewelin / main.ino
Last active February 5, 2022 03:30
Anders Skivspelare
//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.cpp
Last active November 17, 2017 20:38
Policy gradient reinforecment learning pinball game Catch Circles but Avoid Rectangles
///Add advanced game avoid rectangles but catch circles
///Fix bugg in pinball_game.hpp (was work on raspierry pi but not on PC) replay_count was not set to 0 at init state. Now replay_count=0;
/// Only dependancy is OpenCV C++ library need to be installed
/// Update with gamma parameter now
/// 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.
@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
@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.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.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 / 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 / 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 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;