Archive

Rant

A big chunk of my master’s career has been dedicated to finding good perceptual hash functions. What separates ‘good’ from ‘bad’ functions is not difficult — low false-positive rate, low false-negative rate. That much is easy to benchmark. Really, though, what we want to optimize for near-identical image matching is the narrow range of boundary cases where images are similar, but not exactly identical. That’s a much more subjective area where a binary right/wrong isn’t as helpful as ‘how wrong’. This is particularly relevant in our case, as we need to be able to sort images based on how similar they are to an input image.

To better visualize the performance of our hash function we perform the following test. A small set of 1500 images are loaded. Each image is permuted in one of five ways; the identity (no change), rotation, pixel noise, scaling, and cropping. Each of these is hashes and appended to a list of all hashes, then a matrix is formed with inter-hash differences. (This is referred to as a ‘similarity matrix’, usually.) The result of the current method can be seen below:

NN Hash Distance Table

On the diagonal (where x=y) you’ll see the series of black squares. This is to be expected since the difference between something and itself is zero. An ideal equation would have blocks of 5×5 black pixels with the remaining area white or nearly white, suggesting a very high distance between an image and its dissimilar neighbors. You can note in the hash above that it’s quite liberal — assigning a smaller distance between differing images. Contrast it with the pHash grid below.

pHash Distance Table

pHash is much more selective overall, and more effective as a metric (if significantly slower). It says to me that there’s still a lot of work to be done on our hash function before it’s production ready.

One step closer to the HTC U Wot M8.

A few months ago I clumsily dropped my Samsung Galaxy Nexus with a USB cable attached. The device was fine up until I ran over it with my rolling chair. It still works more or less normally, but the USB connection is tenuous and requires a very delicate touch. This is frustrating in development and makes using it as a GPS impossible. (The cable won’t stay in on its own.) For environmental and guilt reasons, I generally avoid buying new phones. I picked up an HTC One M7 off Amazon for around $200.

This is not the best choice I’ve ever made.

I spent a long while researching the hardware and comparing the battery life (concern #1) and other, less important hardware details. When finally pressed to decide between the HTC M7, Samsung Galaxy S4, and the Xperia Z2, I went with the cheaper of three evils. The device’s hardware is outstanding and the build quality is top notch. I have some minor discontentment with the inset of the top and side buttons, but these trifles in the larger scope. What upsets me most about this device (though it could be great) is the software component.

Caveat: I have had very little time to really experiment with the device. These are first impressions, but they will color the lasting impressions I will have of the device. I will do my best to avoid confirmation bias, but I am not convinced that I can fully overlook my initial feelings on the matter.

Some things that bother me:

  • Bloatware: Verizon has installed six applications, including the NFL app, which cannot be uninstalled.
  • Blinkfeed uses an entire screen and can’t be removed. (No, the two different approaches to removing it do not work.)
  • Blinkfeed, after I finally decided to give it a shot, does not appear to have a way to add custom RSS feeds. (The approaches I found online do not appear to work.)
  • Holding down the power button, by default, puts the device to sleep. To allow shutdown, you have to go into the settings menu and disable ‘Enable Sleep’.
  • Facebook cannot be uninstalled.
  • I need to request an unlock code to unlock my bootloader from HTC. I applied to be a developer, was accepted, and then pulled my code from fastboot, but this was rejected. I shouldn’t have to request an unlock in the first place. I paid for the device, let me do with it what I please.
  • Unlock screen requires me to drag a lock before entering my PIN. It would be nice to just enter my PIN.

There are critics of the critics who say that the detractors are opposed only because the interface is different. I don’t agree with this sentiment. Surely, it’s wrong to hate something ONLY because it looks different, but I think the criticism of the HTC Sense UI is valid because it behaves in a way that’s different from standard, established UI paradigms with no apparent benefit. Part of making good UI is using components in a uniform or intuitive way. Have you ever used a door with a vertical bar where you had to push? I bet as soon as you grabbed that bar, the first thing you did was pull. Bad UI? Yes. It’s because when we grab something we’re accustomed to pulling it. Have you seen a flat plate on a door near the pivot? I bet you’d push it. The sense UI takes the established tropes of the Android user interface and twists them ever so slightly. If you’re going to deviate from the established path, you better have a REALLY good reason for doing so. Imagine if a Windows application switched the minimize/maximize/close icons from the top right to the top left without reason. Also, every modal dialog has ‘Cancel’ and ‘Okay’ switched. “That’s how we’re doing it now!” You might be a little upset. I see no advantage (not to say one doesn’t exist) from decisions like, “No more multitask button. Now you double-tap home.”

Blinkfeed is a waste, frankly. I know a number of people love the pretty array of blocks folding through their screen, but this is useless to me. The prescribed solution is, and I’m not making this up, ignore it. Really. There is NO option to remove it. That being the case, I decided to give it a whirl. I wanted to add a news feed from SMBC-Comics. I know they have an RSS feed. Blinkfeed doesn’t seem to support adding RSS feeds. Let me say that again, the NEWS FEED APPLICATION DOES NOT SUPPORT NEWS FEEDS. You are stuck using their preselected news items or, alternatively, getting a live fountain of eschewal direct from Facebook. (I’m told that it’s possible to use an ADB command to add a news feed. I’ll try this later, but it shouldn’t be necessary to use an ADB command to get that done.)

I’ll continue to use sense for the rest of the week. When I finally snap and can’t take it any more, I’m going to install Cyanogenmod. It’s the only remaining option I can see.

Overall, I’m disappointed and a little irritable at the experience. Had I purchased this phone from a retail store, I’d return it through the window with a note attached.

Android development has improved by a few leaps and bounds since the last time I touched it, but it’s still fraught with numerous tiny inconsistencies and gotchas. One I ran into recently came in the form of writing to an SD card. In my AndroidManifest.xml, I added the WRITE_EXTERNAL_STORAGE permission. Three times I failed, not sure why despite the permission I was still getting access denied.

Attempt 1:
“<uses-feature android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />”
If you don’t see the issue, that’s okay. The problem was I used ‘uses-feature’ instead of ‘uses-permission’.

Attempt 2:
“<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />”
This time I used the correct tag, but had the uses-permission _inside_ the application tag.
This compiled and ran without problems, but led to the permission error I mentioned above.

Attempt 3:
Okay, move the tag outside of the application. Should be okay? Compiled alright (still). Run. Crash — permission denied. The problem? The tag came after . I’m no expert, but I’m fairly certain that the order of tags inside a manifest should be pretty irrelevant. {“a”:10, “b”:20} is the same as {“b”:20, “a”:10} in my mind. Sibling nodes have no ordering guarantee. (In my world at least.) But you can’t always get what you want. After moving the permissions above the application tag, everything went well.

It’s not hard to imagine that this sort of hiccup would be baffling and upsetting to a newcomer. Make note of this as one more edge to file off the SDK.

A letter sent from Richard Feynman to a student.

Dear Koichi,

I was very happy to hear from you, and that you have such a position in the
Research Laboratories. Unfortunately your letter made me unhappy for you seem
to be truly sad. It seems that the influence of your teacher has been to give
you a false idea of what are worthwhile problems. The worthwhile problems are
the ones you can really solve or help solve, the ones you can really contribute
something to. A problem is grand in science if it lies before us unsolved and
we see some way for us to make some headway into it. I would advise you to take
even simpler, or as you say, humbler, problems until you find some you can
really solve easily, no matter how trivial. You will get the pleasure of
success, and of helping your fellow man, even if it is only to answer a
question in the mind of a colleague less able than you. You must not take away
from yourself these pleasures because you have some erroneous idea of what is
worthwhile.

You met me at the peak of my career when I seemed to you to be concerned with
problems close to the gods. But at the same time I had another Ph.D. Student
(Albert Hibbs) was on how it is that the winds build up waves blowing over
water in the sea. I accepted him as a student because he came to me with the
problem he wanted to solve. With you I made a mistake, I gave you the problem
instead of letting you find your own; and left you with a wrong idea of what is
interesting or pleasant or important to work on (namely those problems you see
you may do something about). I am sorry, excuse me. I hope by this letter to
correct it a little.

I have worked on innumerable problems that you would call humble, but which I
enjoyed and felt very good about because I sometimes could partially succeed.
For example, experiments on the coefficient of friction on highly polished
surfaces, to try to learn something about how friction worked (failure). Or,
how elastic properties of crystals depends on the forces between the atoms in
them, or how to make electroplated metal stick to plastic objects (like radio
knobs). Or, how neutrons diffuse out of Uranium. Or, the reflection of
electromagnetic waves from films coating glass. The development of shock waves
in explosions. The design of a neutron counter. Why some elements capture
electrons from the L-orbits, but not the K-orbits. General theory of how to
fold paper to make a certain type of child’s toy (called flexagons). The energy
levels in the light nuclei. The theory of turbulence (I have spent several
years on it without success). Plus all the “grander” problems of quantum
theory.

No problem is too small or too trivial if we can really do something about it.

You say you are a nameless man. You are not to your wife and to your child. You
will not long remain so to your immediate colleagues if you can answer their
simple questions when they come into your office. You are not nameless to me.
Do not remain nameless to yourself – it is too sad a way to be. now your place
in the world and evaluate yourself fairly, not in terms of your naïve ideals of
your own youth, nor in terms of what you erroneously imagine your teacher’s
ideals are.

Best of luck and happiness. Sincerely, Richard P. Feynman.

I’ve had problems in academia as of late. My grades are fine, but the spark that brought me in with the hope of making things work seems to be lost in the turmoil of auxiliary stressors. I have several classes (and a quite full time job) which do a good job of burning through my concentration before I’ve had enough time to sit and form a thought on a fun project. I’ve taken to game development maybe because it’s artistic in a way that machine learning is not. I don’t have to find the derivative of the weight gradient or figure out a mapping from input to feature space. I can just throw pixels on the screen and make things happen. That’s among the more relaxing things I can do as a programmer. It’s on par with solving Project Euler problems, but doesn’t have the guilt associated with not having anything to show at the end of the day. Perhaps some of the relaxation comes from being able to store the entire application in wetware — being able to cache the entire codebase. I miss having that spark in my academic career and I have concerns that I’ll be too burnt out by the end to be of any use in another workspace. (I could stay at my current job, in theory, but that’s not something I see myself doing in five years any more, especially not in Philadelphia.) So the question sits: “What is the problem to solve?” I keep opening up BitBucket and GitHub and looking at the dozens (really) of image search engines I’ve written over the past few years. I like the idea. It is both useful and niche enough that success will guarantee some amount of publicity. I’ve never launched a search engine though, which seems to indicate something is going wrong. Instead of making progress on them I’m fucking off on HN or making video games or watching YouTube. Is this a shortage of attention? A lack of will? Or is it an indicator that I’m trying to digest a problem of the wrong size? Perhaps it’s symptomatic of the state of academic computer science — anything worth doing is not worth doing again. “Publish state of the art or public novel, but it must be groundbreaking.” This mantra and the entire implicit ideal of publishing for acceptance stands in fairly stark contrast to Feynman’s words and to a commonly held philosophy in the game jam world: “No game is too small. No scope is too limited. If you’re making a game, you’re doing it right.”

I guess I have to find a tiny problem to chew on. Maybe I’ll implement linear regression in an obscure language.

This week’s Freakonomics unpacked the idea of stigmatizing failure. In short, don’t be afraid to fail. Failure shows you something that didn’t work. If at all possible, it’s better to fail to hit a deadline than complete something incorrectly. Among the techniques discussed in the podcast was the ‘pre-mortem’. Unlike a post-mortem, which investigates the things that went wrong and caused a patient to die/project to fail/rocket to explode, the pre-mortem asks everyone on a team to pull together an imagine that the date is three months after the spectacular failure of a project. “Assume the project has indeed failed, and it has failed completely. When people whisper to one another bitterly in the halls about it, what’s the narrative? How did it fail? Give as many details as possible.” This approach cleverly repositions the team naysayer/skeptic/demoter as someone who is trying to help the team. Really, the team as a whole now has a valid channel for predicting the failures of a project. In much the same way, I’d like to share my concerns about what’s going to happen in SAGJ9.

1) Deployment issues. It’s hard enough to get people to play your game without asking them to download Java. Worst case scenario will have judges going through the trouble of pulling down the JRE and the game, only to finally have it crash on startup because the shell is sitting one directory level below the library folder.

2) Gameplay issues. Is this going to be fun? The idea of an angry Bob Ross was amusing and charming, but neither is on its own a sufficient condition for a good game. When the prototype is done on week 1, will it be at all fun?

3) Development issues. The image comparison function could completely fail to correctly/effectively score user submissions, frustrating the users or, worse still, completely breaking forward progression in the game. Will I be able to maintain my enthusiasm when I get to the boring parts?

Number three has been a problem for my entire life. I have a surplus of attentional deficit, and leap from interesting project to interesting project as the boring bits surface. This means a lot of smoke and a lot of spinning tires, but little in the way of forward movement. A thousand half-finished projects don’t look as good as one finished project.

Lastly, I’d like to give a shout out to SA forumgoer, IRC poster, and all around chill dude, Poemdexter. He gave a talk recently on finishing projects. The slides are available here: http://bit.ly/AoGJSlides and his website is http://poemdexter.com It’s hard to think of anyone who is more capable of getting stuff done, so you should listen to his advice.