Powered by Squarespace
This form does not yet contain any fields.

    Entries in tools (5)

    Sunday
    Aug092009

    SIGGRAPH rocks

    As many of you know, SIGGRAPH 2009 has just finished. Every year a lot of really amazing stuff happens there. And this year was not an exception at all! So, in this post I want to highlight some things that seem like something-that-can-not-be-missed stuff to me.

    • Futuristic computer-human interaction. Touchable holography, augmented and virtual reality. And something that is really funny - scratchable input.
    • NVidia has released OptiX, SceniX and CompleX. You have waited for it for a long time and now you’ve got it! CUDA-based real-time raytracing API together with scene management and scalability tools is (will be soon) available to graphic developers for free.
    • Scalable visualization with NVidia Quadro Plex.
    • Metal printing of your own 3d models with Shapeways.
    • OpenGL 3.2 was released.

    I’m pretty sure that there were a lot of another amazing stuff there that I’ve missed. Unfortunately, I’m not a SIGGRAPH attendee, so the only sources of information available to me are my rss subscriptions to different news channels. If you have found something cool at SIGGRAPH, post comments with links here. I’ll be glad to see some other mind-breaking innovations. I love all that future-is-now things a lot!

    Update:

    SIGGRAPH Slides from NVidia have been made available there.

    Thursday
    Jun252009

    Simple K-fold cross-validation tool for MATLAB

    MATLAB has a function for cross-validation, crossvalind. But it’s not very useful when you need to perform many experiments for different learning algorithms. That’s why I’ve implemented little tool for performing k-fold cross-validation experiments. Each experiment run can be parametrized with any learning algorithm and loss function. All you need is to wrap all your learning stuff in a bunch of simple MATLAB functions and then pass those functions as a parameters to the CrossValidation function.

    Currently there are provided a few wrappers for the classification and regression algorithms presented in MATLAB: decision trees, SVM, KNN and generalized linear models. Three loss function are also provided: RMSE, MAD and misclassification loss.

    Currenlty I am using this tool very intensively at work, so new versions with more algorithms, loss functions and features are likely to appear.

     Tool is available here.

    Wednesday
    Apr222009

    Bayesian inference for boys

     

    Learning something is good. Learning something using interesting examples is even better. Today I’m going to show you the power of bayesian inference by building model representing probability of you having some sex. If you want more formal introduction, please read this paper written by Christopher Bishop, famous researcher from Microsoft Research Cambridge.
    Bayesian inference is a method for finding posterior distribution of dependent set of random variables, when some variables are observed and some aren’t interesting. That set of variables is often represented as so-called graphical model: a directed graph called Bayesian network or undirected graph called Markov network. In that kind of graph vertices represent random variables and edge connecting two vertices mean that variables associated with that vertices are dependent. That representation is not only clean and obvious, but it also allows using some fast and robust algorithms for performing inference.
    Let’s look at concrete example. We’ll try to build simple model describing sexual relationships between boys and girls. Probability of you having sex with some girl mostly depends on the degree of she liking you (which depends on you sexuality) and her so-called slutness. I’ve also considered some gaussian noise in woman’s head that sometimes dramaticaly imacts on her decisions. An assumption that slutness and sexuality are distributed normally around zero (which we consider as an average value for that variables) and value describing how much she likes you is also distributed normally around your sexuality allows us to build simple graphical model. Amazing tool for that is Infer.NET, .NET library for bayesian inference from Microsoft Research. Model code is quite short:

     


    Variable<double> youAreSexy = Variable.GaussianFromMeanAndVariance(0, 1).Named("you're sexy");
    Variable<double> howMuchSheLikesYou = Variable.GaussianFromMeanAndVariance(youAreSexy, 0.25).Named("how much she likes you");
    Variable<double> slutness = Variable.GaussianFromMeanAndVariance(0, 1).Named("her slutness");
    Variable<double> randomNoiseInHerHead = Variable.GaussianFromMeanAndVariance(0, 0.25).Named("noise in her head");
    Variable<bool> willYouHaveSexToday = (howMuchSheLikesYou + randomNoiseInHerHead + slutness > 0).Named("will you have some sex?");

     

    After compiling model in Infer.NET you’ll get a graphical representation of your model which is called factor graph. It looks very similar to bayesian network but also contains special “factor” nodes representing different operations, constrains and distributions. Clickable picture below is an example of factor graph for our “sex” model:
    Let’s ask some questions to our model using ExpectationPropagation inference algorithm:
    1. slutness = -5 (she’s REALLY not a slut), willYouHaveSexToday = true (yeah, you did it). Then distribution of you being sexy is Gaussian(3.514, 0.3635) which means you are beauty as a devil (I guess).
    2. slutness = -0.5 (she’s just a girl), youAreSexy = -1 (you are not a good one). Then probability of you having sex today is 0.01695. It means that your chances are quite small.
    3. youAreSexy = -5 (oh, you look really bad), willYouHaveSexToday = true (but still have some sex? strange, isn’t it?). Then distribution of her slutness is Gaussian(3.514, 0.3635) (oh, she is a slut… that makes sence).
    So, bayesian inference helps us with different questions about girls, sex and everything. Remember that provided model is very simple and inaccurate. For example, one can consider slutness as a variance of howMuchSheLikesYou variable or add some other random variables and factors into model. Have fun with it and don’t forget that math is great.

     

    Thursday
    Apr022009

    Good news

    They've finally added .NET support into MATLAB! There are many limitations still, but a journey of a thousand miles starts with one step, right?

    Wednesday
    Feb112009

    C++ vs C#

    I totally hate C++. And every day my hate grows up. But that is not just about my programming language religion. We should look deeper.

    I know C++ pretty well. I’ve read all the stuff like Effective C++, More Effective C++ and Modern C++ Design and understand all of it. And it was really hard. Now I can do amazing things with templates and write robust error-free code. Do I want it? No. It is still really hard for me (and for everyone, I guess) to write, read and maintain such a code. That snippet looks really ugly in C++:
    for (std::vector<double>::iterator it = values.begin();
    it != values.end();
    ++it)
    DoStuff(*it);
    And here is it’s C# equivalent:
    foreach (double value in values)
    DoStuff(value);
    And I’m pretty sure (I have some experience, you know) that 99% of equivalent code pieces are much more simple in C# than in C++. When you read and maintain a lot of code, it is very important.
    Next, I hate includes. There is no good reason for good programming language to have such a non-obvious and non-robust way to incorporate different subsystems or just pieces of code. Really! IDE can do it for me! In .NET there are no problems with include paths. And I can just reference some library to get access to it’s components. No precompiled headers, no include (or lib) directory setup. That’s all about rapid and easy development.
    And the last thing that’s important for me: in most cases (except of writting really performance-sensitive code) you should not care about memory deallocation at all. Execution environment can do it for you. Rather quickly. And it does. How much errors have you ever had with memory allocation and deallocation in C++? I have a lot. More than any other kinds of errors. It’s like a pain.

    But, of course, C++ is fast. Really fast. In computer vision and 3D rendering there are a lot of very performance-sensitive stuff. And the only choise you have is to code it in C++. But don’t forget: there are wrappers for everything. There is XNA, Emgu.CV and CUDA.NET. There is much more than that. You can still write performance-sensitive code in a managed environment with all it’s benefits.

    I forget to mention wonderful tools for .NET developer such a Resharper, FxCop, StyleCop and many others. There are no technical possibilities to create such a useful and powerful tool for a non-managed language like C++.

    Let’s sum up:
    .NET (C#)
    1. Easy language to code, read and maintain.
    2. No problems with library version control, includes and stuff.
    3. Fast and robust garbage collection.
    4. Very powerful standart library.
    5. Cool IDE and tools.
    6. Quite fast.
    C++
    1. Really fast.
    2. There is Boost.
    So that’s my proposal: when you want to code something, think about implementing it in C# first and consider C++ as the last option. I’m pretty sure you’ll like it as much as I do.