Can a variable length, i.e. input_dim=None
, be applied to a simple neural network? Specifically, the Keras Sequential model. I've been running into errors when trying to employ the same concept. I've already seen the documentation that seems to support this functionality:
https://keras.io/getting-started/functional-api-guide/
But when I do the following...
model = Sequential()
model.add(Dense(num_feat, input_dim = None, kernel_initializer = 'normal', activation='relu'))
model.add(Dense(num_feat, kernel_initializer = 'normal', activation = 'relu'))
model.add(Dropout(.2))
model.add(Dense(num_feat, kernel_initializer = 'normal', activation = 'relu'))
model.add(Dropout(.2))
model.add(Dense(num_feat, kernel_initializer = 'normal', activation = 'relu'))
model.add(Dropout(.2))
model.add(Dense(ouput.shape[1], kernel_initializer = 'normal', activation = 'linear'))
...I get this error:
ValueError: ('Only Theano variables and integers are allowed in a size-tuple.', (None, 63), None)
Any help, ideas, or clarification would be greatly appreciated!!
No, you can't. (And you can't with the functional API either)
The weight matrix has a fixed size and this size depends on the input dim.
The possible variable dimensions are:
input_shape=(None,channels)
input_shape=(None,None,channels)
input_shape=(None,None,None,channels)
input_shape = (None, features)
batch_shape
or batch_input_shape
instead of input_dim
batch_shape=(None,input_dim)
or batch_input_shape=(None,input_dim)