A Factoid: The Enforcing-Inheritance-Generic-Thing-in-Kotlin

I learn a Kotlin thing everyday.  Today’s thing, “Enforcing-Inheritance-Generic-Thing-in-Kotlin” (I’m terrible with names and terms, there’s an official term for this that I cannot remember).

I have a function that starts an activity for a result.  I want to limit this function to only be able to start activities extending an abstract class, FooActivity.

In Java:

private void start(Activity activity, Class<? extends FooActivity> cls) {
   // some stuff with intents
}

In Kotlin:

fun start(activity: Activity, cls: Class<out FooActivity>) {
    // some stuff with intents
}

That’s it.  Read more about generics in Kotlin here.

1 Percent Better Everyday

I’ve been following James Clear for some time now.  He shares a lot of helpful advice on building and maintaining important habits.  Checkout his talk where he discusses his methodology for bettering yourself, 1% everyday.

TrafficFlow – An Update

Early this year I started a project, TrafficFlow.  The goal was to train a neural network to recognize, with reasonable accuracy, congested traffic conditions.  I needed data, so every 3 minutes I was sampling a NC DOT traffic camera at I-40, exit 289.

This camera, and many others, can rotate.

(Above are images taken from the same traffic camera, one when it’s facing West, the other Facing East)

It would be interesting to see how the neural network responds to this type of data.  My guess was I would have ended up with a low accuracy because of the differing angles and most times, there was not a lot of data samples depicting traffic congestion.  I would have needed a lot more training data.  This forced me to find a new camera and one that is fixed.  I found one in Downtown Durham.

It’s even reasonably lit at night.  I’ll be sampling this traffic camera every 3 mins, meaning I’ll have enough data (hopefully) to start training a neural network in a week or two.  In the meantime, I’ll be doing a few exercises in deep learning, starting with this, Building powerful image classification models using very little data.

Learning TensorFlow

Adam Geitgey, is one of many engineers helping to spread machine learning knowledge to the rest of us.  His course, Building and Deploying Applications with Tensor Flow, is free this weekend through Monday, August 7th.  If you are interested in learning some of the basics of TensorFlow, this course does a great job.  It’s accessible, quick, and has some code to go along with it.

Cover slide from LinkedIn Learning

I finished it in a couple hours and feel like I have a good base of knowledge to build on.  After a pretty chill and relaxing summer, I’m working on restarting TrafficFlow, project where I build a TF model that can predict whether a snapshot from a traffic camera contains congestion.  This course is just one of many pieces of documentation and knowledge, I’ll be leveraging.

Building and Deploying Applications with TensorFlow on LinkedIn Learning

Edit: Check out a similarly structured lesson on Keras 2.0 – Building Deep Learning Applications with Keras 2.0

The Real Threat of AI

Kai-Fu Lee writing an opinion piece for the New York Times:

Unlike the Industrial Revolution and the computer revolution, the A.I. revolution is not taking certain jobs (artisans, personal assistants who use paper and typewriters) and replacing them with other jobs (assembly-line workers, personal assistants conversant with computers). Instead, it is poised to bring about a wide-scale decimation of jobs — mostly lower-paying jobs, but some higher-paying ones, too.

This transformation will result in enormous profits for the companies that develop A.I., as well as for the companies that adopt it. Imagine how much money a company like Uber would make if it used only robot drivers. Imagine the profits if Apple could manufacture its products without human labor. Imagine the gains to a loan company that could issue 30 million loans a year with virtually no human involvement. (As it happens, my venture capital firm has invested in just such a loan company.)

We are thus facing two developments that do not sit easily together: enormous wealth concentrated in relatively few hands and enormous numbers of people out of work. What is to be done?

Being in the tech industry and having done a lot of work in automation, this is something I often think about.  Artificial intelligence and machine learning are enabling companies to hire fewer people (or hire people for more specific roles).  Those who get hired or keep their jobs are doing the work that cannot be easily automated and relying on software tools for tasks that used to be fulfilled by people.  A significant portion of those savings benefit shareholders aiding the phenomenon, “the rich get richer”.

I’m still hopeful that new types of innovative, creative, and well compensating work will appear, but in the meantime, our society needs to be able to handle the influx of the newly unemployed.  People who lose out because of larger economic forces, entirely out of their control, need to be able to retrain and remake themselves for a new economy.  Instead, we (the US) are cutting social services like healthcare and reducing investment in community colleges and universities. Seems like we should be doing the opposite.