Looking for simple examples of keras vector of floats to single float output

484 views
Skip to first unread message

Michael Shulman

unread,
Sep 20, 2017, 2:13:18 PM9/20/17
to Keras-users
Hi, I'm relatively new to neural nets, and completely new to keros. I've installed it under anaconda with python 3.5.2. I'm looking for simple examples to get off to a good start learning keras, but every example I've seen is for a classifier, that is, vector of (typically) float inputs mapped to a classification output. That is, the output is an integer mapped to a small range of values. For example, if 5 classes, then output is limited to integers 0 - 4. But that's not what I'm looking for. I want to train a NN to be a non-linear function from a vector of floats to a single float output, where the output is, as often as possible, reasonably near the "correct" value. Can anyone point me at simple examples of keras code that do this, instead of implementing a classifier? Thanks!

blackhol...@gmail.com

unread,
Sep 20, 2017, 5:14:02 PM9/20/17
to Keras-users
Hi Michael,

I've just recently created a "Getting Started with Keras" playlist on YouTube. New topics are being added almost daily. While I don't think any of the videos there so far will directly cover the particular example you'd like to see, this would be a good resource for you for starting out.

https://www.youtube.com/channel/UC4Huog4qcFfGrq_y7vKMJvg

Matias Valdenegro

unread,
Sep 20, 2017, 6:23:51 PM9/20/17
to keras...@googlegroups.com
Hi,

You just need to change two things in the model to transform it into a
regression one:

- Make sure the last layer outputs a single value, with an appropriate
activation function. Remember to also normalize your output values and put an
activation that matches the range of your normalized output values.
- Change the loss function to something like mean squared error or mean
average error.

And if there is accuracy in the model's metrics (model.compile call) then you
should remove it as accuracy makes no sense for regression.

Michael Shulman

unread,
Sep 21, 2017, 8:47:21 AM9/21/17
to Keras-users
Thanks, blackhol... and Matias, both of you helped me a lot. Also, I finally found what looks like a relevant web link:

https://machinelearningmastery.com/regression-tutorial-keras-deep-learning-library-python/

With the help of this tutorial, Matias' technical information, and blackhol's YouTube presentations, I expect to learn this stuff fast.

- Michael

Reply all
Reply to author
Forward
0 new messages