2
$\begingroup$

According to what I've read, the output layer of a neural network is going to either perform "classification" or "regression". In regression, a numerical value is chosen on a single output node, and in classification, a choice is made of the "best" or "favorite" answer. If my output layer were to represent an image, it needs to have an output neuron expressing a value for each pixel, but I'm not sure how to do this. Is it even possible? I'm wondering because the examples of regression I've seen have all been using multiple variables to predict one value. I want multiple inputs to predict multiple outputs.

$\endgroup$
5
  • 2
    $\begingroup$ Sure, it's possible; you can think of it as regression with a vector-valued output. But it's going to be hard to learn a useful model. $\endgroup$
    – Danica
    Mar 6, 2015 at 2:43
  • $\begingroup$ Could you perhaps point to a reference where I might see an example implementation of such a thing? $\endgroup$
    – Rich
    Mar 6, 2015 at 6:17
  • $\begingroup$ There are even examples of neural networks taking two images as inputs and outputting an image which is a hybrid of both. $\endgroup$
    – Sycorax
    Feb 24, 2017 at 20:26
  • $\begingroup$ @Sycorax Could you please elaborate? This is something I am quite interested in. Thanks! $\endgroup$ Sep 13, 2017 at 18:39
  • $\begingroup$ @CharlesParr github.com/jcjohnson/neural-style $\endgroup$
    – Sycorax
    Sep 13, 2017 at 19:35

2 Answers 2

1
$\begingroup$

I implemented a simple variant of this. Some example images are included for convenience: https://github.com/iver56/image-regression

$\endgroup$
0
1
$\begingroup$

For black-white images place logistic activation(it will have 0-1 range) at the output layer for each pixel. Then rescale the pixel intensities to this range. For example if your intensities are 0-255, divide by 255. For RGB you can model each channel separately.

If you apply the same normalization idea to input layer and feed the same image to input and output then you are effectively building an image compression tool. I did this before the compression artifacts are really funny lines (reflecting the linear operation at each node) very much different from JPEG compression.

The output of the hidden layer is the compressed image, while the first layer acts as a compressor and second layer acting as a decompressor.

$\endgroup$
3
  • $\begingroup$ so you are saying instead of interpreting >0.5 to mean true and <=0.5 meaning false, just take the value. Hmm, I'm concerned because the logistic activation function or "sigmoid" is nonlinear -- is there a way to have a linear response? $\endgroup$
    – Rich
    Mar 6, 2015 at 15:25
  • $\begingroup$ Is it a binary image so that you are considering a 0-1 approach? If not you can use linear activation at the output (and at the hidden layer if you like) but you need to clip/cap when you use the network if predicted values exceed 255 or go below 0. $\endgroup$ Mar 6, 2015 at 16:01
  • $\begingroup$ Values between 0 and 1 are perfectly fine. But binary is not what I want. I'm wondering if my question even makes sense. It occurs to me that the term "activation function" implies a binary response. $\endgroup$
    – Rich
    Mar 6, 2015 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.