Thursday, August 23, 2018

Learning Japanese with my Wife (日本語の勉強、妻と一緒!)


It was just a casual talk with a friend on a Social Language Learning App which turned out to be so nice that I will be marrying her soon.

It all started with Japanese learning.
So I would like to share my journey of teaching Japanese to my beautiful wife.

The very first beginning step of learning Japanese is Hiragana, the basic alphabets of the Japanese system.


Here are the main learning points associated with learning hiragana characters.
- words associated with the character
- sound of the character
- stroke order


This site is quite good one to check for strokes.
https://www.yosida.com/en/hiragana.html

Reference :
https://ja.wiktionary.org/wiki


Tuesday, February 6, 2018

CoreML Simple Linear Regressor

Introduction

I started learning basic Machine Learning from last 6 months from Udemy Course.


Machine Learning A-Z™: Hands-On Python & R In Data Science


I am a friend of mine, started to do MLTokyo study session every Saturday. I remember we were so obsessed with it that once we were working for 3 continuous days in Silver Week holidays from morning 10AM to almost 7PM.

I could grasp the fundamentals of Machine Learning algorithms but I still wanted to connect it to my job.
It was just that last year Apple announced the CoreML Framework in WWDC2017 talks.
So it was the perfect timing to apply the studied machine learning.

CoreML is a great Framework.
For those who are new, here's a quick explanation, the image which I have in mind about CoreML.

  • Traditionally, we train ML models on the server side. We need to have good specification server, keeping in mind the time, processing power, and data size required to train the model.
  • Once we are finished with the training, we want to use it from the mobile app. To achieve this, we generally build a wrapper API around the model.
  • The app captures the data and sends it to the API for processing. The model processes the data and returns the results via API back to the app.

So generally a Machine Learning App is built around this architecture.

The problem with above process is that the app constantly needs to be connected to the Internet to be able to process the data.
Also, there's huge network overhead involved with it.

CoreML to the rescue:

CoreML improves this process to a quite extent.

  • The same already trained model can now be exported to a file format (.mlmodel) which can be easily imported into Xcode Project. This integrates the model into your app directly removing the need for overhead API and also making your ML App offline workable.
  • According to the documentation of CoreML, it does supports following Caffe, Keras, scikit-learn, XGBoost, LIBSVM. 
So I thought why not to convert the models trained in the Udemy Course one by one.

My first CoreML integration.

Udemy Course:
- Part 2 - Regression
 - Section 4 - Simple Linear Regression
   Github source code

Xcode Model

APP Preview in Simulator

Since it was a simple Linear regressor, it was quite simple to integrate.
But as I proceeded to integrate Polynomial Regression, I started facing problems of data preprocessing.
I am still stuck on translating PolynomialFeatures into swift code.
It seems like all the data preprocessing has to be re-written in the app code to be able to provide inputs to the trained model.

Although it looks all promising and interesting to integrate CoreML, there are some things which should be taken care of.

  1. App Size will increase depending on the size of the trained model. CNN model trained with 4000 images each for 2 classes yields a 15MB .mlmodel file. This model gets packed with almost same size as .mlmodelc file inside the IPA.
  2. As far as my understanding of the topic is that it is not possible to train the model on the device. So the only prediction can be done from the model. I think there is a provision to update the model from in background of the app, but have not yet explored it.

If you like this post and have any comments please let me know.

Happy Machine Learning,
Happy iOS

Understanding Leadership

A leader has to lead the people, have vision, motivate the members. Leader can empower people and nurture them to become future leaders. ...