Reputation: 356
I'm just starting with deep learning, and I've been told that Keras would be the best library for beginners.
Before that, for the sake of learning, I built a simple feed forward network using only numpy so I could get the feel of it.
In this case, the shape of the weight matrix was (len(X[0]), num_neurons)
. The number of features and the number of neurons. And it worked.
Now, I'm trying to build a simple RNN using Keras. My data has 7 features and the size of the layer would be 128.
But if I do something like model.add(Dense(128, input_dim=(7, 128)))
it says it's wrong.
So I have no idea what this input_dim
should be.
My data has 5330 data points and 7 features (shape is (5330, 7)).
Can someone tell me what the input_dim
should be and why?
Thank you.
Upvotes: 0
Views: 441
Reputation: 86650
The input_dim
is just the shape of the input you pass to this layer. So:
input_dim = 7
There are other options, such as:
input_shape=(7,)
-- This argument uses tuples
instead of integers, good when your input has more than one dimension batch_input_shape=(batch_size,7)
-- This is not usually necessary, but you use it in cases you need a fixed batch size (there are a few layer configurations that demand that)Now, the size of the output in a Dense layer is the units
argument. Which is 128 in your case and should be equal to num_neurons
.
Upvotes: 1