20 ms·
Fizz Buzz in Tensorflow
- fayimora 10y agointerviewer: How far are you intending to take this? me: Oh, just two layers deep haha
- LaurenceW1 10y agoI would have given him the job
- gnaritas 10y agoIf that were a real situation, I wouldn't have, he over-engineered the shit out of it and while cool, I prefer devs who can solve simple problems simply; they get more work done for the price.
- gokhan 10y agoThis is not over-engineering. Defining a couple of functions to solve it would be over-engineering, like offloading Fizz to it's own function, Buzz to another one etc. Anything (deliberately) more is just comedy.
- gnaritas 10y agoTraining a neural network to solve fizzbuzz is over-engineering, fun over-engineering, but over-engineering none the less.
- curiousgal 10y agoDepends on the position no? If you are looking for a developer sure. But if you are looking for an engineer, creative solutions are a plus.
- brianwawok 10y agoI prefer employers that don't treat me like a baby, so to each their own ;)
- Bahamut 10y agoWell, when you give a hilariously bad interview question...
- gnaritas 10y agoIt's not a bad interview question, if you think it is, you perhaps haven't had enough experience with candidates applying to programming jobs who talk a good talk but can't program to save their lives.
- TeMPOraL 10y agoWell, technically, as a programmer and not enterpreneur you shouldn't be expected to have "experience with candidates applying to programming jobs who talk a good talk but can't program to save their lives".
- gnaritas 10y agoNo one said programmers were expected to; however, not having that experience makes judgement of what is or isn't a bad question baseless. FizzBuzz and all such trivial code tests are fantastic interview questions because most applications can't program, that is exactly the point and purpose of FizzBuzz, weeding out liars of which there are many due to high salaries in comparison to other fields.
- jawilson2 10y agoYeah, hopefully this kind of question is handled in a phone screen before bringing them in.
- vonklaus 10y agoSometime it is better to hire for culture, someone who is intelligent but also, and this is critical, can take a joke.
- mattmcknight 10y agoMaybe the one-hot binary encoding wasn't the best feature set. Base 3 and Base 5 encodings might have worked better.
- brandmeyer 10y agoStupid question: We are trying to train the network how to calculate modulus of division. Of a binary encoding. Why should we expect this to be learnable in only two layers?
- joelgrus 10y agoYeah, secretly I was surprised that it worked as well as it did!
- nharada 10y agoWhat architecture do you need to get 100% accuracy? Don't forget to use a validation set for the model and hyperparameter selection though!
- brandmeyer 10y agoI suspect that there is no way to predict in advance the smallest model which can represent any given function. However, we should be able to at least develop an intuition for depth and breadth that is sufficient on any given problem. Classically, division circuits are large and complex, so I naively expect a NN built out of add, mul, and Heaviside(x)*x to also be large and complex. As with many models, I suspect that this network really learned some other property that has almost-but-not-quite the same pattern as divisible-by-N.
- wyager 10y agoPretty sure it's been proven that sufficiently large 3-layer networks can learn any function.
- jedberg 10y agoThis whole thing is making fun of asking fizz-buzz to a senior programmer, but yet I've found it to be one of the best phone screen questions possible. For someone who is truly a senior programmer, they knock it out in about 30 seconds and we move on. For the ones who pretend to be senior programmers on their resume, it trips them up and I know right away that their resume is either a pack of lies or their previous coworkers were helping them a lot more than they let on. If I had actually had this person, I would have probably laughed as soon as he did the imports, said, "clearly you think this is a silly question" and then explained why I ask that question. Hopefully we could have moved on from there.
- bstrand 10y agoIt's just a jape, not to be taken seriously, made in the great comic tradition of FizzBuzz Enterprise Edition: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
- ergothus 10y agoJoking aside, this example does a great job to show one of my complaints with common (edit: enterprise) Java practices - Where is the logic?
- vonmoltke 10y agoCommon enterprise OO problems. It is neither confined to Java nor representative of Java as used outside enterprise development.
- ci5er 10y ago> nor representative of Java as used outside enterprise development. It isn't? I've turned down a couple of sweet gigs, at times when I really needed the comfort of work-group structure and maybe even a pay check, because I assumed that (based on my reading) it was all like that. I knew from history, back in the days when it was called Oak that it was a pretty delightful language. Then WS-* and Enterprise OO happened, and I assumed that's where it all went...
- dbcurtis 10y agoThis is the most off the wall and hilarious thing I've seen in a month. For calibration: I spent the whole weekend at Maker Faire.
- arethuza 10y agoI think I'd start with, "Let's define two combinators S and K..." .... Fizz Buzz in combinatory logic, that would be quite entertaining.
- spc476 10y agoIt's been done: https://codon.com/programming-with-nothing https://codon.com/programming-with-nothing
- vvanders 10y agoAnd here I thought that the Haskell style FizzBuzz was clever.
- zardo 10y agoNo wonder you didn't get the job, using a shallow ann when they were probably looking for a pointer network.
- BenderV 10y agoHe should have used a Recurrent Neural Network with Long Short Term Memory so that the neural network won't have been dependent of the maximum number given NUM_DIGITS. Scalability! No wonders he didn't got the job. Joke aside, it's funny how simple machine learning problems can reveal people who think you can just give neural networks anything and output anything, and it will work like magic.
- Bromskloss 10y ago> people who think you can just give neural networks anything and output anything, and it will work like magic. What _is_ the proper method?
- BenderV 10y agoWell, there is a variety of possible answers here. Giving the direct integer ("1", "23") to a simple deep network won't work. - RNN with LSTM might be a better approach, since it will more based on the value of the ordered bits than their "disposition", and could scale to an arbitrary high number. - @zardo mentioned Pointer Network (https://arxiv.org/abs/1506.03134 https://arxiv.org/abs/1506.03134). It looks to solve this kind of problems but honestly I'm discovering it now. - Give the base 3 and 5 of the input would be the fastest solution. (but since it's kind of hardcoding part of the solution, it's more a trick than a general solution). Can anyone correct me what if I got something wrong here? Did I missed something?
- vintermann 10y agoIt also reveals something that's not obvious, but is very clear to anyone who's tried (deliberately or accidentally): Teaching a neural network simply to count is surprisingly hard.
- gertef 10y agoIt would be much more interesting to see a TensorFlow program actually learn to solve FizzBuzz from examples, instead of hardcoding in the logic: if i % 15 == 0: return np.array([0, 0, 0, 1]) elif i % 5 == 0: return np.array([0, 0, 1, 0]) elif i % 3 == 0: return np.array([0, 1, 0, 0]) else: return np.array([1, 0, 0, 0])
- sherjilozair 10y agoThe TF program does learn to sovle FizzBuzz. The above code was used to generate data with which to train the network.
- oh_sigh 10y agoIt's really easy even just hand generate a "neural network" if you assume that the inputs can be preprocessed into base-3 and base-5 representations
- Bromskloss 10y agoAs far as I can see, that function was used only to generate training data. How would you like to see it trained instead? Should it output a string and only be told whether that was the correct output or not for the given input number?
- psb217 10y agoShould've trained to generate the output strings directly, using an LSTM decoder... That would be more end-to-end.
- chestervonwinch 10y agoI can't tell if this guy did this during a real interview, or if that's part of the joke. Maybe that's intentional. Very funny, either way. It reminds of the paper where they use SVM to "visually identify" the matrix rank: http://www.oneweirdkerneltrick.com/rank.pdf http://www.oneweirdkerneltrick.com/rank.pdf
- uhhuhuh 10y agoPlease tell me you really did this. A company name would make my year, but I'll be satisfied with a simple yes/no confirmation.
- namelezz 10y agoGreat post. Both funny and informative.
- ninjakeyboard 10y agoIt's a fun article, but solving the problem with the simplest, clearest solution possible should be the goal and if someone provided this solution I would hesitate to hire them. Yak shaving in training a neural network would actually make me nervous that the candidate would over-engineer solutions. It's not like whiteboarding sleep sort or something for a fast easy clever solution (if impractical and inefficient). The guy who has to maintain this version of fizzbuzz after it's wrote would loose his mind. I'm probably being overly practical - it's a very fun article.
- theoracle101 10y agoLighten up
- e12e 10y agoSeems like a bit of a wasted opportunity to assume input as binary digits, rather than as a sequence of hand-written numbers on the white-board. Then there should of course be a second whiteboard, and a robot arm with a marker for output, along with a pair of cameras for stereo input and feedback while training the robot arm in hand-writing "fizz", "buzz" and "fizzbuzz" ...
- phlakaton 10y agoAll that and it still couldn't get the right answer? With a basic pattern like that? I suspect somewhere Hofstadter is having a good laugh.
- slantedview 10y agoNot that I advocate this approach, but another way to look at FizzBuzz is as a personality test. If a (senior) developer balks at writing FizzBuzz, perhaps it shows arrogance and a lack of humility. It could also be useful to see if the developer follows up to inquire as to why they were asked a FizzBuzz question, and about its relevance to the work. I see this kind of questioning as not only fair game, but good to ask about. Not asking about something that seems out of place could seem off.
- laacz 10y agoI'm absolutely delighted that there is more and more such developer-generated prose with context of recent events. Is there a place where it would be aggregated?
- astannard 10y agoI think this just illustrates the Alpha principle, the interviewer was obviously intimated. This is because they are a Beta interviewing and Alpha. If the interviewer had more imagination and confidence rather than the long pauses it could have been a great learning opportunity!
- _navaneethan 10y ago>>> for i in range(1,101): print "FizzBuzz"[i*i%3*4:8--i**4%5] or i The above line cost your interview :) He might be expecting like this one