What should the last layer be when you're doing a regression with Keras?

2,606 views
Skip to first unread message

alexc...@gmail.com

unread,
Jun 2, 2015, 2:05:09 PM6/2/15
to keras...@googlegroups.com
Hello! Quick question. I want to do a regression (predicting a continuous output) and I'm wondering what should be the last layer for me to do that?

This is my current model: 


Any recommendations? Thanks!

François Chollet

unread,
Jun 2, 2015, 2:20:20 PM6/2/15
to alexc...@gmail.com, keras...@googlegroups.com
Whether or not you should use an Activation as the last layer, and what kind of activation, depends on the range of the values you want to output (for instance: if you want to output negative and positive values, don't use ReLU, etc. And never use softmax since it ouputs a probability distribution). 

If you aren't sure, it's probably better not to use an Activation as the last layer (Dense would then be the last layer).

Also, "show_accuracy" should not be set for a regression problem. The notion of accuracy only makes sense for a classification problem.

--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/9ed667d5-1765-4fc7-9f4a-64dd62872be2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

alexc...@gmail.com

unread,
Jun 2, 2015, 4:12:03 PM6/2/15
to keras...@googlegroups.com, alexc...@gmail.com
Thanks for the reply Francois! Very helpful.

Do you have any other tips for how to do regressions effectively? Most of the examples I've seen have been around classification.

Best,
Alex

su...@oregonstate.edu

unread,
Apr 22, 2016, 1:53:27 PM4/22/16
to Keras-users, alexc...@gmail.com
I think the method you provided is also OK. 
'Efficiency' depends on your data.  The best way for me is to try 'sgd', 'adam' 'rmsprom'...... and see the results....
Reply all
Reply to author
Forward
0 new messages