Installing TensorFlow on CentOS

Google released TensorFlow as open source for community use and improvement. From the site: “TensorFlowâ„¢ is an open source software library for numerical computation using data flow graphs.”

The instructions on tensorflow.org are aimed at Ubuntu and OS X. I had a need to install it on CentOS so I documented the steps in a github gist. Feel free to comment if you find something I missed:

* Updated 8/18/2016 for TensorFlow 0.10
* Updated gist 10/18/2016 to correct typo in epel-release

Presentation on Linear Algebra in R

At our January meeting, I presented on Linear Algebra basics in R. I have been taking the Andrew Ng’s Stanford Machine Learning course. That course primarily uses Matlab (or Octave, and open source equivalent), and machine learning involves manipulating and calculating with matrices. Naturally, being an R person, I have been working with some of the techniques in R.

In order to limit the scope of the talk, I focused on matrices, vectors and basic operations with them. There is a practical example that uses a machine learning algorithm, but it’s just to show how R handles a more involved equation with matrices. The talk is not an attempt to teach machine learning.

The slides are available here, and comments or suggestions are welcome.

Mapping Functions in R

I have been buffing up on some areas of Math that I felt rusty in. One of the tools I was using was my old TI-82 calculator I used in high school.

TI-82 Graphing Calculator

I even got the TI Connect software working where I could download screenshots, etc.

TI-82 Screen Cap of Sin, Cos, Tan

You can put in data sets (see screen cap below), and do some graphing and some statistical analysis.

Data Entry on TI-82

However, mapping functions is a more straight forward use of the calculator. Which got me thinking… How does one do that in R?

I did a little digging. With the traditional R graphics and plotting functions, you would use curve() to draw a function. It works fine, but I like to use ggplot2 when I can.

Turns out ggplot2 supports this well. The following code sample maps the same functions I was mapping on the calculator (sin, cos, and tan from 0 to 2pi radians).

And the resulting graph is…

ggplot2 Trig Function Graphing

Removing Exif Data To Resolve IOS Issues

Related to my last post, I had a bug to fix. The images looked rotate 90 degrees locally, so I used Imagemagick’s convert command to rotate them 90 degrees. They looked right locally, and on the sight when viewed in chrome.

However, iOS was showing the images over-rotated by 90 degrees. It turns out after some digging that the pictures were taking on an iOS device and had saved Orientation data in the EXIF data of the image (metadata). The iOS browser was still honoring that metadata.

Because metadata also has date, time, and location info, a lot of people prefer not to publish EXIF data anyway. Photoshop offers options to remove this data when exporting. I believe GIMP may as well.

But I just wanted to make it part of my process. So I updated the Rakefile from the last post with the following command option from Imagemagick’s convert:

convert input.jpg -strip output.jpg

All is well now. Use your favorite EXIF viewer to confirm success.

Resizing Images in Bulk

I help maintain a site for a craft business. One of the challenges is multiple sizes of images for new stock each year. I used to go through and resize each image manually with a program like Gimp.

I finally got smart and installed ImageMagick.

With a Rakefile, I can pass each image into the convert command with the proper sizing, and get the output into a new folder, ready for upload. The code is shown here:

One catch to keep in mind if you work on a Mac. There can be orientation metadata from some images that OS X will honor, but a browser will not. If your images show up on the web in the wrong orientation, look into ImageMagick convert command’s -rotate option.