Reputation: 1415
I am [obviously] new at this and trying to do multiple target regression with keras, using this as my guide, but I'm having trouble. One thing I am having trouble is how to initialize the Dense layer in the line model.add(Dense(input_dim=4, output_dim=500))
. I think the input_dim=4
is due to the XX_train array having 4 columns but am not sure. I'm also unclear on why output_dim=500
. Where does the value of 500 come from? Is it arbitrary?
I took a look at the keras documentation here, which uses the input_shape
parameter instead, but I'm not sure what values I should use for the units
and input_shape
parameters. Apparently input_shape
only needs to be passed in for the first layer, but for all subsequent layers should the units
argument always have the same value (32 in the example shown in the link)? The documentation defines units as: "units: Positive integer, dimensionality of the output space," but I have to admit I'm not certain what that means. Does it mean that if I'm trying to predict 8 features' values (y_train, y_test), units=8
?
This states I need to pass input_shape
only to the first layer, but it doesn't state how to determine that shape.
What I'm trying to do: I have 11 columns and thousands of rows of data. I'm trying to use 3 of those columns as features to predict the other 8 (which are labeled). I'm probably missing something obvious, but can someone point me in the right direction? For all I know, multiple target regression might not even be the way to go.
Thanks for any help. My apologies for my obvious noobosity. Please let me know if I need to supply any more information.
Upvotes: 1
Views: 775
Reputation: 6044
model.add(Dense(input_dim=4, output_dim=500)). I think the input_dim=4 is due to the XX_train array having 4 columns but am not sure
Yes, that is correct. The input_dim is 4 because XX_train has 4 columns.
Where does the value of 500 come from? Is it arbitrary?
This is found empirically.
Does it mean that if I'm trying to predict 8 features' values (y_train, y_test), units=8?
Yes, that is correct.
What I'm trying to do: I have 11 columns and thousands of rows of data. I'm trying to use 3 of those columns as features to predict to other 8 (which are labeled). I'm probably missing something obvious, but can someone point me in the right direction?
Code snippet, just as a starting point.
from keras.layers import Dense, Activation
from keras.models import Sequential
model = Sequential()
model.add(Dense(32, activation='relu', input_dim=3))
model.add(Dense(64, activation='relu')) # add more layers as necessary
model.add(Dense(8))
model.summary() # use summary() to verify model architecture
Upvotes: 1