Reputation: 4373
I try to use a CNN for a regression task.
My feature data has shape (6097, 30, 32, 9):
the target data has shape
(6097, 1)
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
))
Upvotes: 2
Views: 2192
Reputation: 1179
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))
Upvotes: 3