JSON (De)Serialization of nested objects

During my first encounter of handling JSON (de)serialization in Python, I faced the problem of (de)serializing objects that have properties that are instances of another class. Using the json module, one has to write two methods, a complex_handler and a class_mapper that are fed to json.dumps and json.loads respectively. The design problem here is that the class_mapper needs to compare a dict that is to be deserialized with the properties of potential classes in order to find the matching type. In the first level of deserialization one could potentially provide the type as a parameter to the deserialization-function, but as soon as there is a child property, the type may be unknown. Therefore each class that is to be deserialized has to be registered into a collection of (properties) -> class mappings. To simplify the handling, I wrote the following JsonConvert class: Now we can define some classes and make…

Machine Learning, Uncategorized, Windows 10

Running Tensorflow with native Linux Binaries in the Windows Subsystem for Linux

After 4 hours of unsuccessful attempts to set up tensorflow in Docker on Windows, I decided to – just for fun – try to run it in the shiny new Windows Subsystem for Linux on my Windows 10 Insider Preview Build 14332. What began with low expectations turned out to be very successful, so here are the steps: First enable the Windows Subsystem for Linux in the “Turn Windows features on or off” dialog: Then open the Ubuntu Bash and update the package index: You can now proceed to install pip for Python 2: Now install the CPU-enabled Linux x64 tensorflow package:: Tensorflow is now installed. With the following command, you can get the directory of the installed package: This should give something like “/usr/local/lib/python2.7/dist-packages/tensorflow”. Now let’s cd to the directory with the example implementation of a CNN for the MNIST dataset: And run the convolutional neural network: In the…

C#, Hardware, IoT

RCSwitch for Windows 10 IoT

RCSwitch is a library for controlling remote power sockets from Arduino. The original source code by Suat Özgür can be found on GitHub. In combination with the MX-FS-03V sender MX-05V receiver, I wanted to do the same thing on Windows 10 IoT on my Raspberry Pi. To use RCSwitch in a Windows Universal app, I ported the library into a C++ Windows Runtime Component. The RCSwitch port to the Windows Universal Platform is now available on NuGet. To use it in your IoT project, just install the NuGet package and then copy these code samples: Create an instance of the RCSwitchIO class: Turning remote power sockets on/off: In good .NET fashion, you can also subscribe to an event to listen for incoming signals: However I found that receiving does not work very reliably. Initially I was able to sometimes receive signals, but a few weeks later (with a different remote)…

C#, Machine Learning, Uncategorized

Learn and Predict the Gender of German Nouns

The German language is know to be relatively complicated and especially the gender causes lots of confusion. While English has only one article (the), three different articles are used in German: der (male) die (female) das (neuter) While rules to determine the gender of a noun exist, almost no German native speaker can name them. We can now solve this problem (determine the gender without memorizing the rules) using some simple machine learning with the Accord framework. Let’s quickly name the steps that will follow: find and extract a dataset of noun-gender associations split into training, test and validation dataset extract features into something the algorithm can use train a Naive Bayes test the model with the test dataset After quite a while of searching, I found this machine readable and CC-BY-SA 4.0 licensed XML file from Daniel Naber. In our Universal Windows App we can then load all nouns into…


iGEM Aachen 2014

You might have wondered why it got a bit more quiet on my blog. Now here’s why: Because of the iGEM competition 2014. The iGEM competition is an international competition in synthetic biology that debuted at MIT in 2004. Since then it has grown to more than 230 participating teams from all over the world. Over the last ten years it has significantly shaped the international synthetic biology community. In 2013 a few friends and me heard of the competition and founded the first team from RWTH Aachen. Up until March 2014 our team grew to 15 students of Bachelor and Master programs in Biology, Biotechnology, Biomedical Engineering, Computational Engineering Science and Computer science. After almost a year of hard work, we finished our project “Cellock Holmes – A Case of Identity” and flew to the Giant Jamboree (Finals) in Boston, MS, We had fulfilled all criteria for the gold medal…

C#, Software, Windows 8, Windows Phone, WinRT

Replay Practice

Are you playing an instrument? Yes? Then you probably know what it is like when you’re practicing the same few notes all over again! Sometimes playing it slower can help too. With Replay Practice you can do exactly that. Choose a song, move the markers and loop a part of the song at a speed of your choice. Replay Practice is available for Windows Phone 8.1 and Windows 8 !  

Arduino, C#, Hardware, Root, Windows 8, WinRT

Arduino as a MIDI/Bluetooth Relay for Windows 8.1 Apps

In my last post I described how a Bluetooth connection between Arduino and a Windows 8.1 device can be established. The next step for me was to connect the Arduino to my electronic drum kit which has both, a MIDI-IN and a MIDI-OUT jack, but any other electronical instrument will do as well. The wiring diagram for an Arduino Uno R3 with MIDI-IN/OUT and the JY-MCU Bluetooth module is shown in Fig.1. NOTE: Occasionally there are MIDI shields available for Arduino, so you might not have to build it on your own. The Arduino code to relay MIDI>Bluetooth and Bluetooth>MIDI is actually quite simple. //======================================================authorship //by Michael Osthege (2013) //======================================================includes #include “SoftwareSerial.h” //======================================================constants const int TX_BT = 10; const int RX_BT = 11; const int MIDI_TX = 1; const int MIDI_RX = 0; //======================================================bluetooth setup SoftwareSerial btSerial(TX_BT, RX_BT); //======================================================initialization void setup() {     Serial.begin(31250);     btSerial.begin(9600);     Serial.println(“Bluetooth initialized”); }…

Arduino, C#, Hardware, Windows 8, WinRT

Bluetooth communication between Arduino and Windows 8.1

Introduction Recently, after being inspired by this video of Arduino Bluetooth communication with Windows Phone 8 by Marcos Pereira, I got myself some new devices to play with: Arduino Uno R3 in a starter kit (link) JY-MCU Bluetooth module (link) and a few extra cables The thing is: I don’t have a Windows Phone 8 yet and the Windows Phone 7.8 APIs do not support this kind of Bluetooth communication. But: I have a Surface RT and with Windows 8.1 the RFCOMM API can be used to establish a serial link to the Arduino. Arduino and Visual Studio It happens that my developing skills are quite limited to C# and when I had to develop some Kinect software with Processing in early 2012, I almost freaked out. Arduino code is written in C++  and the standard Arduino IDE is derived from the Processing IDE. Fortunately there’s the Visual Studio extension…