Hey you!

Postcards are cool! Go send some ->

postme.me

Best blogging week I have ever had

Nov 21 2011

Somewhere around June this year I set a challenge for myself. I wanted a sustained 20k visitors every month on swizec.com by the end of the calendar year.

It's a spike!

It's a spike!

The only real step towards this goal was to start blogging regularly. At first I would blog exactly twice a week on specific days, eventualy I started blogging daily.

Here’s the strange thing – it actually worked.

By blogging every day I have ensured not all of my posts will be super brilliant, but the sheer amount of practice I’m getting has meant that even on my worst days I can simply sit down and pump something out. Even if it’s dreck, even if I feel nobody will be interested. Such posts only end up as a reminder for people that hey, there’s this blog, you sometimes like it … it’s still alive. Just letting you know!

Last week something strange happened.

I filled my monthly “quota” in a single week … somehow my little personal blog managed to garner the attention of 32,820 visitors. What’s stranger still, 96% of these visits were from Friday to Sunday. Mostly because of two posts.

Not sure exactly what happened, but apparently people love being told that startups are awesome and why I love working for them. Another thing that really seems to pique people’s interests are strange lines of python.

A good blogging week

A good blogging week

Those two posts together have been tweeted 242 and G+’d 38 times. Strangely though, this does not beat the record holder – a post about apple’s ping being a big pile of steaming dung – which managed to get 248 tweets on its own.

But all these visits and tweets and comments (about 30 per post) don’t mean a single thing without the very important metric of how many people actually read them?

I’m happy to say that the post about startups was read to its completion by about 38% of visitors – for a 1000+ word behemot that’s a lot on the internet. The python post also did remarkably well with a 65% completion rate! Yay!

I think the python post can easily be explained by all the expert pythoners looking for the punchline since it turned out that line wasn’t so much strange as me and my friends are stupid.

Even long posts can have good completion rates

Even long posts can have good completion rates

Short confusing posts do _very_ well

Short confusing posts do _very_ well

You might think the stats for the python post are poisoned by the startup post doing so well, but according to google analytics there was so much significantly more traffic on the python post that this is practically negligible. In fact you can see this in the above cutoff, 11k people on 17th paragraph, and only 1700 on the 18th paragraph, which the python post doesn’t have.

However, I am happy to say that the post about startups has proven remarkably resiliant and it still got more than 1000 visitors even yesterday.

Wonder if I’ll ever manage to repeat something like this.

Also, mixpanel thinks I’m problematic despite my life-time AppSumo account thing.

Mixpanel crying

Mixpanel crying

Enhanced by Zemanta

2 responses so far

Strangest line of python you have ever seen

Nov 18 2011

An example of a NFA state diagram.

Image via Wikipedia

The other day @HairyFotr and @zidarsk8 were doing some codegolfing with implementations of nondeterministic finite state machineand asked me to blog their results.

For those of us who often forget what all of this computer science mumbo jumbo means, here’s a quick explanation from wikipedia:

In the theory of computation, a nondeterministic finite state machine or nondeterministic finite automaton (NFA) is a finite state machine where for each pair of state and input symbol there may be several possible next states.

Essentially they were looking for the shortest implementation of an algorithm that can take a bunch of states, go through all of them on each step and then backtrack to find the solution.

@zidarsk8 doesn’t really know python all that well so his way to optimize things was basically “SHORTEN ALL THE CODES!” and as a result he came up with this line nobody understands.

state = [st for s in state for st in states[(s,letter)]]

At first it looks just like a double loop. But then you notice the right-most for is taking the list to iterate over from its own body, which is the iterator of the left-most for loop …

What?

Seriously, if you can explain how this works you win a lot of internets, eternal fame and I might just send you a box of cookies.

Here’s the whole implementation in case you were wondering

from optparse import OptionParser
from collections import defaultdict
 
def run(beseda):
       a, states = open("machine.txt") ,defaultdict(list)
       state, final= a.readline().split()[1:],a.readline().split()[1:]
       [states[(i.split()[0], i.split()[1])].append(i.split()[3]) for i in a]
       for letter in word:
               state = [st for s in state for st in states[(s,letter)]]
       return any(i in state for i in final)
 
print [(b,"YES") if run(b) else (b,"NO") for b in OptionParser().parse_args()[1]]

According to our best debugging efforts it works as advertised … even though we can’t actually understand why or how it’s even possible that python knows what to do.

For curiosity’s sake, here’s @HairyFotr’s Scala implementation

object NKA extends App {
    import scala.collection.mutable._
    val gates = new HashMap[(String,Char), ListBuffer[String]]
    val lines = io.Source.fromFile("avtomat.txt").getLines.toSeq
    val (init,finals) = (lines(0).split(" ")(1),lines(1).split(" ").tail)
    lines.tail.tail.map(_.split(" ")).foreach 
        {s => gates.getOrElseUpdate((s(0),s(1)(0)), ListBuffer()) += s(3)}
 
    def crawl(state:String, input:String):Boolean = 
        (input!="" && (false /: gates.getOrElse((state,input(0)), return false))
            {_ || crawl(_, input.tail)}) || (input=="" & finals.contains(state))
 
    args.foreach(in => println(in + (if(crawl(init,in)) ": YES" else ": NO")))

If you ask me, this looks like a bunch of gibberish and even HairyFotr says it isn’t the prettiest Scala code out there. But hey, this is codegolf, all that matters is minimizing those keystrokes!

To conclude, two challenges:

  1. Explain how that line of python works
  2. Come up with a shorter solution … I’m guessing golfscript is a good choice

PS: I was serious about those cookies

PPS: an example of what the automata decription looks like http://pastebin.com/QLW1BfFj

Enhanced by Zemanta

33 responses so far

Why I only work with startups

Nov 17 2011

As a freelancer with a tinge of an online presence I often get to be picky about whom I work with. In a sense this ties into my post about the mindset of the current generation- I’m not picky because I get so many offers, I’m picky because I like to enjoy my work.

Tokyo Tower

Image by konishiroku_ via Flickr

This is why I only work with startups.

Yes, I’ve worked with nonstartups before, I no longer want to; enough of that nonsense. Nonstartups are just inherently annoying and horrible to work with, rather than filling me with a sense of pride those projects always make me feel feel like I just sold my body to the ugliest hairyest guy on the block (not that I’ve done this before, I’m guessing)

So what are the top few reasons I love working with startups?

1. Working directly with calling-the-shots people

Having a direct contact to people calling the shots is very important for me. It allows me to get a sense for what they actually want, rather than just what words are coming out of their mouth. This way I can focus my efforst on what really matters when it matters – sometimes it’s just better to Get It Working than doing it right.

In a big corporation orders trickle down through a chain, getting reimagined and reinterpreted on every step and when they finally get to you, there’s only a sense of what you were told to do and all sense of what matters is lost.

2. Impact

Directly tied to the sense of context, is having an impact in the company. When somebody is just starting out with their product, you’re helping to shape their vision, you can give good feedback and make use of your experience – in a sense you’re helping somebody achieve their dream and that’s a Great Feeling ™.

Working as an emotionless engineer, a faceless cog who just gets his part done in the big machine … well I’m sure you can imagine how that doesn’t even begin to compare.

3. The fast pace

Fast gul

Image by aginorz via Flickr

A great thing of a small team is the fast pace everything moves at. Since you’re talking directly to those in charge and everyone shares the vision at least a bit (otherwise why work for this startup?) everything moves quickly. An idea is pushed into the system and a couple of days later it can be implemented and tested.

Conversely when working with an established organization, somebody gets an idea, there is a meeting for those responsible of the creative vision shaping, then a meeting between a representative of the leader class and a representative of the implementation class. Then the implementation class has a meeting of their own. By the time you start working on something months might have passed and even the original idea-giver has probably already lost passion.

4. Interesting work

Some interesting early attempts at suspension.

Image via Wikipedia

The work at startups is usually more interesting as well. Might be because I enjoy working with new technologies and startups are likelier to take a risk with new technology. Or maybe it’s just because I like working on products helping actual people rather than faceless hypothetical entities.

A pain point working for established companies is that you often edn up working on internal tools aimed at internal tools aimed at internal people for internal purposes. Sometimes they never even get pushed into production because some boss up high was fired and the new one must assert his rule.

5. No politics

I haven’t personally had to deal with a lot of politics, but I’ve talked to people working in government all their lives – some times it feels like the sole reason they even go to work is to deal with the other people working there.

You know, instead of doing their job.

6. Self-organization

What I love about small teams comes directly from the fact there are no people whose sole purpose in life is looking after you. Because everyone in a small team is a focused professional a sense of trust is built; people no longer feel like they have to check up on everythign everyone does, you can just give the team some loosely defined orders and they’ll figure it out.

Nigel Harrison's Autonomy - Near MGSM hotel

Image via Wikipedia

Startups in general care more about results than how you actually do something. If you can make a good case for why you chose to do something they way you chose to do it, and if it works, nobody really cares.

In a corporation with many layers of management it becomes much more important for managers to feel useful and so they get int he way. This is also a self-fullfiling prophecy since all the good people leave and in the end you actually _need_ tiger management.

7. Simpler money on clearer terms

Wasn’t sure if I should include this at first, but it’s kind of important.

When it comes to money, big organizations and government-like entities are always convoluted, take forever to pay up and it never goes smoothly. Probably stems from the fact that everyone involved has their cushy job, gets paid a fixed amount of money on the same date every month and they simply have no empathy for the poor freelancer trying to make a living client to client.

I mean, obviously, why should it be a problem to deliver a project quickly and then wait a month to get paid? And what do you mean you’re annoyed when it takes us two weeks to process the paperwork because that one guy is on vacation?

Almost no matter how much you charge these people it always feels like you aren’t being paid enough to deal with their bullshit.

In a startup there’s none of that. Everyone involved is much more down to earth and respects the feeling of urgency when it comes to money. I like that.

Conclusion

To sum it all up, working for startups is more enjoyable and personal, more interesting on a technical level and generally free of that feeling like you’re trying to run with an open parachute strapped to your back.

Anyone working with big corps care to disagree?

Enhanced by Zemanta

43 responses so far

I suck at implementing neural networks in octave

Nov 16 2011

A few days ago I implemented my first full neural network in Octave. Nothing too major, just a three layer network recognising hand-written letters. Even though I finally understood what a neural network is, this was still a cool challenge.

Yes, even despite having so much support from ml-class … they practically implement everything and just leave the cost and gradient functions up to you to implement. Then again, Octave provides tools for learning where you essentially just run a function, tell it where to find the cost and gradient function and give it some data.

Then the magic happens.

Getting the basic implementation to work is really simple since the formulas being used aren’t all that complex:

Neural network cost function

Neural network cost function

Neural network backpropagation

Neural network backpropagation

Here’s the code I’ve come up with to get this working on a three layer network:

function [J grad] = nnCostFunction(nn_params, ...
                                   input_layer_size, ...
                                   hidden_layer_size, ...
                                   num_labels, ...
                                   X, y, lambda)
%NNCOSTFUNCTION Implements the neural network cost function for a two layer
%neural network which performs classification
%   [J grad] = NNCOSTFUNCTON(nn_params, hidden_layer_size, num_labels, ...
%   X, y, lambda) computes the cost and gradient of the neural network. The
%   parameters for the neural network are "unrolled" into the vector
%   nn_params and need to be converted back into the weight matrices.
%
%   The returned parameter grad should be a "unrolled" vector of the
%   partial derivatives of the neural network.
%
 
% Reshape nn_params back into the parameters Theta1 and Theta2, the weight matrices
% for our 2 layer neural network
Theta1 = reshape(nn_params(1:hidden_layer_size * (input_layer_size + 1)), ...
                 hidden_layer_size, (input_layer_size + 1));
 
Theta2 = reshape(nn_params((1 + (hidden_layer_size * (input_layer_size + 1))):end), ...
                 num_labels, (hidden_layer_size + 1));
 
% Setup some useful variables
m = size(X, 1);
 
% You need to return the following variables correctly
J = 0;
Theta1_grad = zeros(size(Theta1));
Theta2_grad = zeros(size(Theta2));
 
yy = zeros(size(y),num_labels);
for i=1:size(X)
  yy(i,y(i)) = 1;
end
 
X = [ones(m,1) X];
% cost
for  i=1:m
  a1 = X(i,:);
  z2 = Theta1*a1';
  a2 = sigmoid(z2);
  z3 = Theta2*[1; a2];
  a3 = sigmoid(z3);
 
  J += -yy(i,:)*log(a3)-(1-yy(i,:))*log(1-a3);
end
 
J /= m;
 
J += (lambda/(2*m))*(sum(sum(Theta1(:,2:end).^2))+sum(sum(Theta2(:,2:end).^2)));
 
t=1;
for t=1:m
  % forward pass
  a1 = X(t,:);
  z2 = Theta1*a1';
  a2 = [1; sigmoid(z2)];
  z3 = Theta2*a2;
  a3 = sigmoid(z3);
 
  % backprop
  delta3 = a3-yy(t,:)';
  delta2 = (Theta2'*delta3).*[1; sigmoidGradient(z2)];
  delta2 = delta2(2:end);
 
  Theta1_grad = Theta1_grad + delta2*a1;
  Theta2_grad = Theta2_grad + delta3*a2';
end
 
Theta1_grad = (1/m)*Theta1_grad+(lambda/m)*[zeros(size(Theta1, 1), 1) Theta1(:,2:end)];
Theta2_grad = (1/m)*Theta2_grad+(lambda/m)*[zeros(size(Theta2, 1), 1) Theta2(:,2:end)];
 
% Unroll gradients
grad = [Theta1_grad(:) ; Theta2_grad(:)];
 
end

This then basically gets pumped into the fmincg function and on the other end a result pops out.

Now, I’ve managed to vectorize this thing to the edge of my capabilities. But I know it’s still just matrix multiplication so I know for a fact it should be possible to vectorize even further. Anyone know how to do that?

Also, if you know of a cool way to generalize the algorithm so it would work on bigger networks, I’d love to hear about that as well!

Enhanced by Zemanta

5 responses so far

We are not generation sell

Nov 15 2011

William Deresiewicz wrote yesterday in the new york times that the current generation is generation sell- that they care about nothing more than selling themselves, their product or both. There was a clear hint that this is particularly bad and that a society of agreeable twenty somethings who would never do anything against the status quo or anyone in particular lest it damage their reputations and hurt their brand is simply bad.

The Planet of Youth

Image via Wikipedia

As a guy in his early twenties I am firmly a part of this generation and we are anything but generation sell.

There is a bigger undertone of counter culturalism in this generation than William gives us credit for – at least here in Europe. He says that we start our own businesses, one man shops dedicated to a single cause or to a single individual, that small time entrepreneurship is the norm rather than the exception.

Starting a business might seem normal in the US, but here in Europe almost everyone older than 28-ish values a steady job over taking an opportunity, it is still considered odd to change jobs every couple of years. Even at-will employment is fantasy here, once somebody is an employee they have to practically kill somebody to be fired.

But the youth has invented at-will employment – we freelance. More and more individuals, especially in creative jobs, are freelancing and working on a contract, switching employers every couple of months rather than every decade.

Ask a random twenty something what they want three years from now and you will mostly get a blank stare. This is not because of a lack of ambition, it’s because we have no faith in stability. The world has been pretty clear that it is not willing to provide any sort of stability; so we’ve learned to live without.

There is a massive shift in the mindset of this generation. We value freedom, personal expression and enjoying what you do more than anything. Sure, there were entrepreneurs and people following their dreams before us, but when was the last time young people were turning down jobs en masse because the employer just didn’t make the cut? And in a bad economy!

Unemployment is at unprecedented levels all around the world, especially among the young. “There are no jobs” the news channel keeps crying, but what they actually mean to say is “There are no jobs we want to take”. How many of those unemployed are people doing contract work? Possibly circumventing the job system entirely?

Youth in Revolt (film)

Image via Wikipedia

I understand there is a massive lack of everyone from plumbers to car mechanics, they collect more money per hour than most middle class makes in their office jobs … but the youth isn’t after the money.

We simply don’t make decisions based on monetary outcomes. We put much greater value on self-fulfillment and enjoying what you do even if it means living on the edge of poverty.

But don’t get me wrong, when we do find that project we’d enjoy working on we won’t skimp on asking for a proper rate – might even move on if the employer proves insufficient; or doesn’t have a fun enough culture; or simply because they restrict twitter and facebook access during office hours.

In that regard you could say we are generation entitlement.

But it’s not that simple – we are the first generation growing up with cheap instant global communication and that changes the perception of how much we are worth as humans, of what we want with our lives.

You could say we are the first global generation. For the first time in history all the youth of this world is part of the same generation at the same time. Walter Isaacson writes in Steve Jobs‘s biography that a significant moment in his life was creating the Blue Box so he and Woz could make free phone calls anywhere in the world.

Now imagine how different the world is when cheap global communication is placed in your crib.

There is no more lag.

When hippies were around Europe was so far behind, the heyday was already over before my parents found out about how awesome hippies were. Punk was all the rage in the 70′s, for Slovenia punk is a thing of the 80′s – and the hotbed of punk is a mere 2 hour flight away!

Content publishers still try to create artificial barriers for the spread of culture – we simply steal the culture we want. Television lags a year or two behind the US here in Slovenia, so we just steal the content to watch it when it actually comes out.

I think you could say we are generation workaround.

No jobs? Fine, we’ll create our own. Barriers for culture spread? Fine, we’ll spread it ourselves. Government in the way? Fine, we’ll just ignore it. Big corporations being annoying? Fine, we’ll just ignore those too.

In a way this is the first generation where the hacker culture has permeated everyone. Hacker culture used to be that paragon of do-it-yourself fight the corporate overlord and the government as well. They valued creating cool things and ideas.

The OWS and Anonymous movements are a prime example of this. Both were born on the internet – one fights against oppressive corporations, the other against oppressive governments. They spread throughout the world like wildfire. There are no demands for sweeping policy change, there is no cry for a better world, it’s basically just a big “Fuck you! We’ll create our own better world and leave you in the dust!”

And that is what we are, we are generation fuck you.

Enhanced by Zemanta

5 responses so far

TV’s are now computers O.o

Nov 14 2011

The television set I grew up with left our place yesterday. It’s actually kind of odd, as my hometown has changed year to year, as I went to different schools, changed my computers, my tastes in culture, even most of the furniture I’m using … the one thing that has always stayed the same was the family television set.

The old telly

The old telly

I still sort of remember the shopping trip when we brought it home with my dad. I must have been around four years old, which would make that TV around twenty years old now.

Twenty long years.

And now it’s gone. It went quietly, without fanfare, nobody gave it two thoughts. As simple as moving a big lump of glass and electronics and plastic down four flights of stairs without a lift. For the last year you even had to use a toothpick to turn on our dear telly, and lately the image was all flickery and without colour.

And then we plugged in the new one.

Holy mother of god, what televisions have done in the past 20 years! That thing is a freaking computer!

Hell, you have to politely ask it to recognise all manners of external devices, even the set-top-box needs to politely introduce itself! The menus and dials indicate that something as simple as a sound system needs a warm introduction as well.

Sexy new telly

Sexy new telly

Yep, that telly rules the living room and it knows it. I’m sure whenever the television is off it sings sexy and I know it quietly in its own ear.

The most technologically interesting bit I’ve found so far is the ethernet port on the back.

Apparently you can connect the television (should I be calling this thing a stripped down computer?) to your home network and stream movies right from a computer – obvious choice here would be my linux box holding the collection of roughly 960GB of video … why do I have that much again? Guess that happens when you have FTTH.

There’s problem with this epic feature though. The telly is still not a computer and can’t just browse stuff on the network. Nope, needs something called a UPnP Media Server to stream the files. Unfortunately, the internet is very scarce with information about this (or I suck at looking for it), but the best I’ve found so far is MediaTomb.

No luck so far getting the TV to recognise this server exists on the network and playing the files. Brilliant success playing HD movies from a portable disk though …

Another useful feature on these modern television set things is the internet. Sure, it’s a stripped down internet reduced to a bunch of icons, sometimes called apps, that you can use discretly rather as a proper browser, but hey, when was the last time you watched youtube and vimeo videos on a telly?

Or used facebook and twitter for that matter?

There’s probably some way to hack this, there’s bound to be support for a real browser deep down in the bowels of this OS … but I will restrain myself from looking for it. This is the family telly, not one of my computers and is not a playground.

Oh and perhaps most surprising of all, the UX is good.Up to par with, if not better than, with iOS. No joke. Philips knows what they’re doing. I was highly surprised!

Now if only Siol put a UX even remotely as good on their set-top-box I’m sure everyone would be a happy camper.

edit: I just discovered that the telly does in fact have a full blown browser

Enhanced by Zemanta

Comments Off

Parsing JavaScript with JavaScript

Nov 11 2011

Over the weekend I started working on llamaduck- a simple tool that aims to figure out whether your code will run on the newly released node 0.6.0. Eventually it might be able to perform other compatibility assessment tasks as well, but I’m focusing on simple stuff first.

southridge-56gold-111105-891.JPG

Image by Scott Trotter via Flickr

Or at least I thought it was simple.

The list of API changes since 0.4.x doesn’t seem that long and it should be easy enough to digest. But as it turns out, I spent almost all of Sunday just figuring out how to turn javascript into a beautiful analyzable AST.

If you don’t know what an AST is – it’s a so called abstract syntax tree, which means it should look identical regardless of what the actual syntax is. Although it will differ for actually different languages. So a coffeescript AST should look the same as JavaScript, but Python’s will differ.

My research came up with three options:

  1. Take a parser generator and a JavaScript grammar, hope for the best
  2. JSLint has a parser … somewhere around line 2000
  3. Uglify-JS supposedly has a parser too

The only viable option was uglify-js. It’s a neatly packaged node.js module that does a bit more than I need, but at least it’s got an easy to use parser with an exposed api interface.

Score!

Here’s an example of a file that outputs its own AST to give you a feel for what I’m talking about:

var parser = require('uglify-js').parser;
var util = require('util');
 
(function get_ast (path, callback) {
    require('fs').readFile(path, 'utf-8', function (err, data) {
        if (err) throw err;
 
        callback(parser.parse(data));
    });
})('./example.js', function (data) {
    console.log(util.inspect(data, true, null));
});

The file parses itself and outputs a tree encoded as a javascript array (scroll past the insanity, there’s a bit more text there):

[ 'toplevel',
  [ [ 'var',
      [ [ 'parser',
          [ 'dot',
            [ 'call',
              [ 'name', 'require', [length]: 2 ],
              [ [ 'string', 'uglify-js', [length]: 2 ],
                [length]: 1 ],
              [length]: 3 ],
            'parser',
            [length]: 3 ],
          [length]: 2 ],
        [length]: 1 ],
      [length]: 2 ],
    [ 'var',
      [ [ 'util',
          [ 'call',
            [ 'name', 'require', [length]: 2 ],
            [ [ 'string', 'util', [length]: 2 ], [length]: 1 ],
            [length]: 3 ],
          [length]: 2 ],
        [length]: 1 ],
      [length]: 2 ],
    [ 'stat',
      [ 'call',
        [ 'function',
          'get_ast',
          [ 'path', 'callback', [length]: 2 ],
          [ [ 'stat',
              [ 'call',
                [ 'dot',
                  [ 'call',
                    [ 'name', 'require', [length]: 2 ],
                    [ [ 'string', 'fs', [length]: 2 ], [length]: 1 ],
                    [length]: 3 ],
                  'readFile',
                  [length]: 3 ],
                [ [ 'name', 'path', [length]: 2 ],
                  [ 'string', 'utf-8', [length]: 2 ],
                  [ 'function',
                    null,
                    [ 'err', 'data', [length]: 2 ],
                    [ [ 'if',
                        [ 'name', 'err', [length]: 2 ],
                        [ 'throw',
                          [ 'name', 'err', [length]: 2 ],
                          [length]: 2 ],
                        undefined,
                        [length]: 4 ],
                      [ 'stat',
                        [ 'call',
                          [ 'name', 'callback', [length]: 2 ],
                          [ [ 'call',
                              [ 'dot',
                                [ 'name', 'parser', [length]: 2 ],
                                'parse',
                                [length]: 3 ],
                              [ [ 'name', 'data', [length]: 2 ], [length]: 1 ],
                              [length]: 3 ],
                            [length]: 1 ],
                          [length]: 3 ],
                        [length]: 2 ],
                      [length]: 2 ],
                    [length]: 4 ],
                  [length]: 3 ],
                [length]: 3 ],
              [length]: 2 ],
            [length]: 1 ],
          [length]: 4 ],
        [ [ 'string', './example.js', [length]: 2 ],
          [ 'function',
            null,
            [ 'data', [length]: 1 ],
            [ [ 'stat',
                [ 'call',
                  [ 'dot',
                    [ 'name', 'console', [length]: 2 ],
                    'log',
                    [length]: 3 ],
                  [ [ 'call',
                      [ 'dot',
                        [ 'name', 'util', [length]: 2 ],
                        'inspect',
                        [length]: 3 ],
                      [ [ 'name', 'data', [length]: 2 ],
                        [ 'name', 'true', [length]: 2 ],
                        [ 'name', 'null', [length]: 2 ],
                        [length]: 3 ],
                      [length]: 3 ],
                    [length]: 1 ],
                  [length]: 3 ],
                [length]: 2 ],
              [length]: 1 ],
            [length]: 4 ],
          [length]: 2 ],
        [length]: 3 ],
      [length]: 2 ],
    [length]: 3 ],
  [length]: 2 ]

Conclusion

Now we have a simple tree we can recursively analyze and look for incompatibilities. But before anything really practical can be done I need to figure out how to track variable scope. That’s really the hard bit because the code needs to check when variables become a critical section and then confirm that they do in fact eventually get used in a critical way.

But once that nut is cracked llamaduck will be a neat little tool useful for many things.

If you’ve got some coding inclination, I’d love a helping hand over at the llamaduck github repo.

Enhanced by Zemanta

5 responses so far

Timekiwi – delicious timelines

Nov 10 2011

Timekiwi vertical timeline

Timekiwi

Timekiwi is a beautiful new tool that lets you create a timeline of your social life in a single easy to digest interface.

Right now six services are supported: Twitter, Facbook, Tumblr, Foursquare, Instagram and Flickr. Just clicky click and a shiny timeline is waiting for you to behold. I was lucky enough to see the beta version, which had even more flare about it – instead of creating a timeline you squeezed kiwis. That was a nice touch :)

Since I don’t have Facebook timelines yet I can’t quite compare with that, but what I can do is compare with lifepath.me … although I’m not sure how lively that project is anymore since @dcurtis sold it as soon as facebook announced its timelines.

Conceptually I believe timekiwi is much closer to facebook’s timelines than it is to lifepath since it’s meant as a display of your meaningful tweets (no retweets or conversations) and photos to dial the flare up to eleven. Whereas lifepath was more about putting significant events in your life on a timeline without aggregation.

Anyway, I shall shut up now and let you bask in the glory of some screenshots of Timekiwi.

Timekiwi entry page

Timekiwi entry page

Timekiwi vertical timeline

Timekiwi vertical timeline

Timekiwi horizontal timeline

Timekiwi horizontal timeline

What’re you waiting for? Go get a timekiwi!

Enhanced by Zemanta

Comments Off

I think I finally understand what a neural network is

Nov 09 2011

Last night I was consumed with watching lessons from the online machine learning class at Stanford. The topic was neural networks, or rather the finer points of forward and back propagation.

Every time I have wanted to learn how neural networks work it just didn’t click. Anyone I asked mostly just waved their hands and said that something magical happens and … but let’s start at the beginning.

The basics of neural networks is that you have neurons that are connected to other neurons. At one end you enter your input data and on the other end the neural network produces some numbers according to what it has learned. Everyone can imagine this much and it’s not really difficult to visualise.

It looks like a bunch of circles with arrows:

Simple neural network, Italian nouns

Image via Wikipedia

Anyone who’s studied this a tad further can tell you the connections between neurons are very important and the weights associated with them are somehow used in calculating stuff. Not a hard concept to grasp – every neuron outputs a number that is multiplied with the weight on each connection before being fed as an input into the next neuron.

Where it always got a bit hairy for me was trying to understand what do the neurons do? The most I could get out of anyone supposedly knowing this stuff is that “it calcualtes stuff”. Yes but how? What does it do? What exactly?

Nobody knew.

Last night I finally figured it out! Neurons don’t do anything. They don’t even exist per se. In fact a neural network looks pretty damn odd inside a computer, it’s really just a matrix of weights.

What happens when you’re doing forward propagation (using a learned network) is simply this:

  1. Take the outputs from the previous layer (a vector of numbers)
  2. Multiply with a vector of weights (the arrows)
  3. Apply the cost function (this becomes the new layer)

Then you just repeat this for all the layers and that’s that. That is literally all that happens.

In the end you are left with a vector of numbers representing the output layer, which you then just have to correctly interpret.

The part I don’t have completely figured out yet is the backpropagation. This is the bit where neural networks learn how to do their magic. Basically backpropagations sets those weights from step 2 via a simple hill climbing algorithm … it is essentially a way to calculate the gradient of the cost function so that you can correctly change the weights to achieve ever lower differences between what you’re supposed to know and  what you actually know. Eventually you hope to achieve a global minimum, but you are guaranteed to at least achieve a local minimum and not being able to tell whether it’s global.

That’s it. That is really all there is to it. Neural networks are just a nice way to visualise a sequence of matrix multiplications. And I guess it’s easier to get grants for “neural networks” than “sequence of matrix multiplications” …

Enhanced by Zemanta

5 responses so far

Going to the dentist is like trying out a new opensource project

Nov 08 2011

Roughly six or seven years have passed since I was last at the dentist’s and after having been putting off making an appointment for just over a year now I finally decided to man up and go make an appointment today.

IMG_3265

Image by simply.jessi via Flickr

Of course, the last time I was there I was in high school and somebody, probably mum, simply told me when and where to go and that was that. I may even have been on some sort of reoccuring pattern and the dentist told me when to come next time or something. Don’t really remember.

Since I’m now a bit older this means an appropriate dentist isn’t even in the same building anymore. Luckily the new building is across the street.

So I go there and immediately have to make a decision. This thing is like a huge repository of stuff … think of it like github. You are greeted with a big sign essentially saying “Some interesting projects this way. There are some that other way as well. Oh and some are upstairs”

Picked the Dentist project and walked through a door.

The project consisted of roughly two modules. There was a big Waiting Room module, which I think doubles as a homegrown community forum, an RTG module – might be just a single executable. There was also a module looking more like a collection of executables, called Dentists.

Naturally there was no documentation. Well, I’m lying, of course there was some documentaiton. A document listed all the executables in this project and there was a document suggesting I should have a running OS before I attempt to use an executable … something about things being pricey if I don’t.

You look at these executables and nothing makes sense.

Every executable is described only by its name. Other than that the only information was one executable advertising itself as just having moved to a different location, presumably within the same project, and another saying I should not under any circumstances try to execute it first.

45

Image by &TheBitGoesOn via Flickr

In a sense this was the worst open source project I ever attempted to use. There was no indication of a project owner or anyone I could contact in case I had any questions. The community forum also looked particularly dead … there was one member online but I think he was idling and probably wouldn’t answer my questions even if I asked.

There were some more executables around the corner, but nothing that could really explain what’s going on here or what the entry point for the project is. Where to start picking it apart and figuring out how to use this thing.

Oh and I also found some random piece of documentation that said all executables have a latency of roughly a month or two. Although I’m not certain how this is useful if you can’t even run them in the first place … maybe they run as a server and you have to somehow issue a request?

All in all a really baffling and confusing experience. In the end I just left. Think I need to find someone with experience using this project or some sort of tutorial …

Enhanced by Zemanta

Comments Off

« Newer - Older »

« @donalddesantis is wrong about... I think I finally understand what... »