2

I try to use a CNN for a regression task.

My feature data has shape (6097, 30, 32, 9):

  • 6097 records
  • 30 timesteps
  • 32 histogram bins
  • 9 channels (image bands)

the target data has shape
(6097, 1)

  • 6097 records with crop yield (float) data.

When I create the last Dense layer of my CNN regression model, I am not sure which settings to use. The output dimension of the last convolution layer is (None,2,2,512). I've added a BatchNorm and Flatten layer (not sure if this makes sense)

What is the correct number of units and the activation function? My guess is units=1 and activation function = "None"

Keras:

model.add(Dense(units=1,
                activation=None
                ))

enter image description here

Rutger Hofste
  • 4,073
  • 3
  • 33
  • 44

1 Answers1

2

That depends on the kind of result you want, often times a linear activation function is used to simply map the value back (it does not change it). Here is a brief explanation on the choice in the output layer. Here is an explanation on regression that also briefly mentions the output layer. The amount of units was already correct.

model.add(Dense(units=1,
                activation='linear'
                ))

Or for the same result:

model.add(Dense(1))
a-doering
  • 1,149
  • 10
  • 21
  • I applied standardization to my target data so the mean = 0 and std = 1. Is that good practice and does it change my activation function options? – Rutger Hofste May 14 '19 at 15:24
  • I believe that it can be arguable whether it is good. It limits your choice of activation functions, beacuse it means that your target data will be normally distributed around 0, meaning it will also have negative values. Some activation functions can not output in the negative values, e.g. ReLu. Other activation functions like TanH can only output in the range [-1,1] and would therefore not return larger values. – a-doering May 14 '19 at 15:32