Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate input_dim for a keras sequential model?

Keras Dense layer needs an input_dim or input_shape to be specified. What value do I put in there?

My input is a matrix of 1,000,000 rows and only 3 columns. My output is 1,600 classes.

What do I put there?

  1. dimensionality of the inputs (1000000, 1600)

  2. 2 because it's a 2D matrix

like image 740
user798719 Avatar asked Apr 28 '17 09:04

user798719


People also ask

What is Input_dim in Keras?

input_dim is the number of dimensions of the features, in your case that is just 3. The equivalent notation for input_shape , which is an actual dimensional shape, is (3,)

How many dense layers do I need?

It's depend more on number of classes. For 20 classes 2 layers 512 should be more then enough. If you want to experiment you can try also 2 x 256 and 2 x 1024. Less then 256 may work too, but you may underutilize power of previous conv layers.

What is the meaning of model Sequentil () in Keras?

From the definition of Keras documentation the Sequential model is a linear stack of layers.You can create a Sequential model by passing a list of layer instances to the constructor: from keras.models import Sequential from keras.layers import Dense, Activation model = Sequential([ Dense(32, input_shape=(784,)), ...


1 Answers

input_dim is the number of dimensions of the features, in your case that is just 3. The equivalent notation for input_shape, which is an actual dimensional shape, is (3,)

like image 145
Dr. Snoopy Avatar answered Sep 28 '22 11:09

Dr. Snoopy