Wednesday, June 29, 2016

Deep Learning

I'm currently reading a book on deep learning and I have to say, it's quite interesting.  Apparently a lot of the machine learning methodology in use today has been around for a very long time, circa 1950 or so, and in fact some of today's methodologies have even been simplified compared to past models.  Only with the advent of big data is there enough training data available to be able to train some models adequately.

And combine big data with the computational resources available currently, it's no wonder we're seeing a resurgence in AI research.  Exciting times in the world of computer science to be sure.  Now where's my self driving car???

Tuesday, June 3, 2014

Time to learn some Q

Ever since coming across this maddness I've found J and the APL family of languages quite interesting.  To the unfamiliar the beginnings of the J interpreter look to be something akin to an IOCCC entry.  But then how and why would brilliant sounding guys like Ken Iverson and Arthur Whitney be coding like this?  Through a bit of research I've learned that this style can actually make code much simpler to read, almost like a book in fact.  Or that's the claim at least.  I've yet to really make any headway with that fragment, so I myself am not a yet a convert.  Perhaps actually learning an APLish language will help.

I've briefly touched on J off and on over the years but never really buckled down.  This time around I'm switching to one of it's successors, Q.  A free 32 bit version of the interpreter (and kdb+) can be found here.  On Linux, simply extract it to where you want it to reside, set $QHOME to that location, and put $QHOME/l32 in your shell's path.  Run "q" and you're good to go.  If your machine is running a 64 bit OS you will need 32 bit compatibility libraries however.

I've already started in on this tutorial.  So far so good.

Tracking progress through old code

It feels good to have a look at some older code you've written and see that you've most definitely improved.  I'd urge everyone to try it.

I've recently been learning more Ruby by doing problems on Code Abbey.  The very first problems involve summing integers that are passed in via standard input.  My original solution turned out to be as follows:

numbers = []
numberStrings = gets.chomp.split
numberStrings.each {|number| numbers << number.to_i}
sum = 0
numbers.each {|number| sum = sum + number}
print "#{sum.to_s}\n"

And this is fine, in that it works. But were I to code this today it would simply read like this:

puts readline.chomp.split.map(&:to_i).reduce(:+).to_s

Of course it's the exact same thing conceptually, but Ruby-wise, it's a vast improvement.

So, have a look at some of your own code my friends. You may be pleasantly surprised at the progress you've made.

Tuesday, September 18, 2012

Online courses

There's been quite a number of free online courses popping up recently, with the 3 major players being CourseraUdacity, and edX.  The amount and quality of content is really exciting.  Not only am I personally able to take advantage of these programs but so are people all across the world, many of whom wouldn't otherwise have access to a university education.

Of the three, Udacity is definitely the most accessible.  Not only does it have very entry level courses, but the lectures are split up in to very manageable chunks.  On top of that the courses are self paced so there are no deadlines to worry about.  And while all 3 platforms do it, Udacity really seems to shine in how it intersperses quizzes and exercises with the lectures. It keeps you very engaged with the courses.  Almost all of Udacity courses are computer science courses however, so if computer science isn't what you're after then you're mostly out of luck.

Coursera material, from math to history, to art, varies widely. On the computer science end material seems a bit more rigorous and advanced than Udacity.  This combined with the fact that courses are on a deadline makes things feel closer to an actual university.  However one problem with Coursera, in my opinion, is the quality and quantity of what I guess could be called the homework.  A lot of it seems far too simplistic and there isn't enough of it to really drive home the material.  The programming projects though are not nearly so trivial so perhaps it all evens out.

edX, with its Circuits and Electronics course, seems closest of all to an actual university offering.  There are both lectures and recitation videos, a full textbook is available, the homework is very appropriate, and there's even lab work in the form of a circuit simulator.  Like Coursera, edX courses do have deadlines, so depending on your point of view this is one downside.  Still, I have to say I'm very much enjoying their program and am definitely looking forward to edX's upcoming introduction to programming course.  If it's going to be anything like the Abelson Sussman lectures it's going to be spectacular. The downside to edX is that it seems to suffer from a lack of content, but hopefully this will change in the future.

Considering the cost, namely free, all three sites are wonderful additions to the Internet.  It's going to be a lot of fun watching them mature.

Outputting Data in Binary.


C++ doesn't have an easy way to print out an integer in binary, so I ended up rolling my own method today.  I vaguely recall doing this before but I'm fairly certain I targeted a particular data type.  This time around I figured I might as well just use templates so I can handle any data type.

All this just so I could let my brain be lazy and not have to mentally translate hex to binary.  Which of course I was doing to make sure I was feeding proper input to a rather meaningless probability experiment.  I'm not so sure I took the easy way out at this point.

Along the way, the precedence of the bitwise operator & caused me some grief.  It's lower than the == operator so my expressions were unexpectedly evaluating to true.  I learned a bit of history as to why things seem brain damaged.

Anyhow, here's some code:

template <typename T>
void toBinary(T data) {
  unsigned char *currentByte = (unsigned char *) &data;
  unsigned char mask = 0x01;
  std::string byteString;
  std::string output = "";

  currentByte = currentByte + sizeof(T) - 1;

  //loop through each byte of data
  for (int i = sizeof(T); i > 0; i--) {

    //convert each byte to a binary string
    byteString = "";
    for (int j = 0; j < 8; j++) {
      if (*currentByte & mask) {
        byteString = "1" + byteString;
      } else {
        byteString = "0" + byteString;
      }
      *currentByte = *currentByte >> 1;
    }

    output = output + byteString;
    currentByte--;
  }
  std::cout << output << std::endl;
}

Fedora 18.

It's 2am.  I barely managed to squeak in my Coursera homework today.  I'm still getting over my cold or making it worse at this point.  Is there a better time to try out Fedora 18 alpha? Not likely.

Just like the F17 live cd there is no firmware for my wireless nic, which is annoying.  Nautilus, the file manager, is refusing to mount my Windows and Linux partitions which is even more annoying. Still, my wireless problems are easily remedied by manually mounting things and grabbing the firmware off my f17 install.  After reloading the driver for my nic I'm good to go.

Right away this has me salivating for the final f18 release.  I really like some of the UI simplifications and some of the new applications sound quite interesting.   The new installer is just plain beautiful.  Unfortunately the installer isn't quite mature.  I'm unable to do anything but use free space for an install.

Switching to the dvd installation media solves the firmware issue, which is good to know, and existing partitions even show up.  But things still aren't fine grained enough for me to be able to specify which particular disk a partition is going to live on.  Looks as though I'm going to have to wait for the beta at the very least.  Given my inexperience with btrfs I don't exactly trust myself to come up with a sane kickstart file.


Blog Time!

I'm starting a blog apparently.  I should have done this ages ago, but better late than never.

If nothing else this is going to be a great spot to collect for future reference some of the various things I run into on the internet.  But maybe, just maybe, some of the tips and tricks I happen to find, or experiments I run, will come in useful to someone.