Coding & AI — oliver-ernst.com

And no, it’s not in Python. Or C++.

It might not even be in a language you already know, based on how relatively unpopular it is. But if you’ve studied math or physics at university you’ve probably at least heard of it.

I’m talking about Mathematica. And since version 11, it’s been possible to train neural networks directly in Mathematica.

Yes. Seriously. Keep reading.

If you’ve ever been interested in symbolic math, let’s get it out there: there’s really no parallel. Matlab just has basic symbolic capabilities, and is not really at all comparable (although both Mathematica and Matlab share the maddening indexing system that starts at one instead of zero…). Similarly, Python’s SymPy is a nice project, but it doesn’t at all parallel Mathematica’s capabilities. Mathematica can take integrals and derivatives, simplify complex expressions, and solve systems of equations analytically. Plus, Mathematica basically invented the idea of computational notebooks, rather than in Python, where Jupyter notebooks were really just an afterthought. …

A tutorial on probabilistic PCA.

There’s hardly a data scientist, scientist, programmer, or even marketing director who doesn’t about PCA (principal component analysis). It’s one of the most powerful tools for dimensionality reduction. If that marketing director is collecting survey data and looking to find target consumer groups for segmentation and analyzing the competition, PCA may very well be in play.

But you may have missed one of the simplest generative models that comes from an alternate view on PCA. If we derive PCA from a graphical model perspective, we arrive at probabilistic PCA. It allows us to:

- Draw new data samples (hence the generative label)…

Open source iOS app for referencing face mask data

Masks are important. Choosing the right type of mask and understanding its qualifications is critical. Currently, mask information is scattered between the openFDA database, FDA websites and CDC websites.

“The Masked Manual” is a free iOS app that shows mask information compiled from openFDA, FDA websites and CDC websites. It lets you easily search for masks and see their qualifications, as well as instructions for wearing it. You can also use the camera to recognize and find your mask by scanning its packaging.

Your state’s voting power in the electoral college.

With the recent 2020 election in the United States coming to a close (or should I say closed?), the arguments about the electoral college are flaring up again. Every four years, citizens in dense population areas argue in favor of either changing or abolishing the electoral college system, citing that their votes are being discounted relative to more rural areas.

What really is your voting power in different states? I made a little Flask application that you can find hosted on Heroku here:

It lets you explore what your vote is really worth based on population data from the 2010 census. I plan to discuss the technology (Flask and some web design) behind creating the app in another post. In this article, I’ll discuss how I measured your state’s voting power, and the stunning power of a handful of small…

And where are they in machine learning?

**You can find the complete code for this tutorial on GitHub here.**

We will review the theory for line search methods in optimization, and end with a practical implementation.

In all optimization problems, we are ultimately interested in using a computer to find the parameters `x`

that minimize some function `f(x)`

(or `-f(x)`

, if it is a maximization problem). Starting from an initial starting guess `x_0`

, it is common to proceed in one of three ways:

**Gradient-free optimization**— don’t laugh! Everyone does this. Here we are just guessing the next parameters:

From UIViewController to screenshot to social media.

You want to implement a share button that takes a screenshot from your app and let’s users share it to social media.

- You want to create a custom image by creating a custom UIViewController.
- You don’t want the UIViewController to show.
- You want to show a nice preview of the image that you’ll share.

**You cant find the complete project on GitHub here.**

Let’s get started with a clean project.

Let’s start with a clean project. Add a share button to the default view controller. For the button image, you can choose `square.and.arrow.up`

…

Back to the bulk of the cake — unsupervised learning — with the latest tools.

Yann LeCunn stated at NIPS 2016:

If intelligence is a cake, the bulk of the cake is unsupervised learning, the icing on the cake is supervised learning, and the cherry on the cake is reinforcement learning (RL).

RBMs are at the heart of unsupervised learning — they’re about finding good latent representations of the data, which can then be used for some supervised task such as classification. They’re also more flexible than other generative frameworks — in contrast to VAEs, for example, the distribution over latent variables in RBMs is learned from data, rather than assumed Gaussian. …

A simple optimization example with Tensorflow 2.0.

I’ve often used `tf.GradientTape`

from StackOverflow snippets, hastily glued together. I’ve also often *not *used `tf.GradientTape`

, and the `minimize`

method usually appears. Finally I’ve separated the two in my mind in a simple application: optimizing a 1D function, e.g. `(x-4)**2`

in one scalar variable `x`

.

The relationship between the two approaches is actually quite simple:

- One optimization method is to use the
`minimize`

method, as documented here, which performs two steps:

- It uses
`tf.GradientTape`

to calculate the gradient. - It uses
`apply_gradients`

to apply the gradients to the parameters.

- The other method is to unpack the action of the
`minimize`

method and manually perform these two steps. …

How close do you have get to deleting everything in your database before you set this up?

I’ve gotten *very* close — not deleting everything, but a nice large collection. Even worse, in the production database, not the development one…. Somehow it all went wrong while writing tests intended for the development database, and a collection was deleted in the production version. Luckily, this time we were able to restore the damage before chaos erupted, but next time, well….

We’ll use Cloud Functions for the backups — another approach is with GitHub Actions or GitLab CI to regularly run the backups, but in this tutorial we only need the native Google products. …

What, when, where, why, and how?

I recently started using Docker, and with that produced an absolute pile of questions. Scraping through Google and StackOverflow for answers, here is a compilation of what I can remember learning on the first day.

Amazingly this isn’t a simple thing.

Docker Hub really just hosts the **images**, not the actual Dockerfile used to make them (assuming they were made from a Dockerfile). You can get lucky by heading to the page for the desired image on Docker Hub, and often you will find a link to a GitHub hosted Dockerfile.

You can also get some idea about the image if you head to `Tags`

and click on the tag you want, and look at the image history. …