Hacker News new | ask | show | jobs
by gertef 3684 days ago
It 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])
3 comments

The TF program does learn to sovle FizzBuzz. The above code was used to generate data with which to train the network.
As 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?
It'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