predict numeric value from images
It seems you are doing it right. The difference between case 1) and 2) should be mainly the loss function (and maybe the activation of the predictions layer). 

For 1) you would use e.g. mean_squared_error, while for 2) you would use the binary cross entropy from logits (logits are what you would feed into a sigmoid or softmax layer). In the keras-documentation it seems like keras does not provide cross entropy from logits as a loss, so you have to set the activation of predictions to sigmoid and use binary_crossentropy. I guess then you could do the If result &gt;0 and &lt;= 0.5 then classify as 0 ..., the result &gt;0 would be taken care ouf by definition of the sigmoid, however you might want optimize the threshold w.r.t. the precision and recall you need.